0

I'm debugging my Android project with C code, the logcat message shows that:

I/DEBUG   (13509): backtrace:
I/DEBUG   (13509):     #00  pc 000106dc  /system/lib/libc.so (dlmalloc+1463)
I/DEBUG   (13509):     #01  pc 0000cf3f  /system/lib/libc.so (malloc+10)
I/DEBUG   (13509):     #02  pc 00011d0d  /system/lib/libutils.so (android::SharedBuffer::alloc(unsigned int)+8)
I/DEBUG   (13509):     #03  pc 00014cf7  /system/lib/libutils.so (android::VectorImpl::setCapacity(unsigned int)+22)
I/DEBUG   (13509):     #04  pc 0007fd79  /system/lib/libandroid_runtime.so (android::TextLayoutValue::TextLayoutValue(unsigned int)+108)
I/DEBUG   (13509):     #05  pc 000811a9  /system/lib/libandroid_runtime.so (android::TextLayoutCache::getValue(SkPaint const*, unsigned short const*, int, int, int, int)+184)
I/DEBUG   (13509):     #06  pc 00081589  /system/lib/libandroid_runtime.so (android::TextLayoutEngine::getValue(SkPaint const*, unsigned short const*, int, int, int, int)+36)
I/DEBUG   (13509):     #07  pc 0007f799  /system/lib/libandroid_runtime.so (android::TextLayout::getTextRunAdvances(SkPaint*, unsigned short const*, int, int, int, int, float*, float*)+42)
I/DEBUG   (13509):     #08  pc 0007c60d  /system/lib/libandroid_runtime.so
I/DEBUG   (13509):     #09  pc 0007c7f9  /system/lib/libandroid_runtime.so
I/DEBUG   (13509):     #10  pc 0001e690  /system/lib/libdvm.so (dvmPlatformInvoke+112)
I/DEBUG   (13509):     #11  pc 0005100f  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+426)
I/DEBUG   (13509):     #12  pc 00027aa0  /system/lib/libdvm.so
I/DEBUG   (13509):     #13  pc 0002ce84  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+232)
I/DEBUG   (13509):     #14  pc 000674bf  /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+374)
I/DEBUG   (13509):     #15  pc 0007066f  /system/lib/libdvm.so
I/DEBUG   (13509):     #16  pc 00027aa0  /system/lib/libdvm.so
I/DEBUG   (13509):     #17  pc 0002ce84  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+232)
I/DEBUG   (13509):     #18  pc 000671a1  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
I/DEBUG   (13509):     #19  pc 0004d2d7  /system/lib/libdvm.so
I/DEBUG   (13509):     #20  pc 0004d391  /system/lib/libandroid_runtime.so
I/DEBUG   (13509):     #21  pc 0004e22d  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+540)
I/DEBUG   (13509):     #22  pc 00000e67  /system/bin/app_process
I/DEBUG   (13509):     #23  pc 000128b3  /system/lib/libc.so (__libc_init+38)
I/DEBUG   (13509):     #24  pc 00000b74  /system/bin/app_process

The message tell me the problem is malloc, it seems the bug is from libandroid_runtim.

How to know what is the problem in my project? Because the message show nothing about my code location, includes java and c.

Please kindly help me to fix this problem. It's bother me for a long time. Thanks very much.

Jar
  • 185
  • 3
  • 10
  • Could it be that you have a memory overwrite in your native code. This could accidentally corrupt the memory block headers used by dlmalloc. Which in it turn could cause a crash like this – user3747345 Jun 19 '14 at 06:51
  • Thanks user3747345, did you have nay idea about how to get the location the memory overwirte? – Jar Jun 19 '14 at 07:21

1 Answers1

1

You got a NULL dereference (that's what the 0x00000000 indicates). Since it's in malloc, that probably means that you corrupted the memory allocator's internal structures by writing outside malloc's returned area at some time before the signal. I would suggest using valgrind to detect that exact point, I think it's usable on Android with some effort.

Tassos Bassoukos
  • 16,017
  • 2
  • 36
  • 40
  • Thank for you replay. I try to use valgrind on android, reference these two pages: [One](http://stackoverflow.com/questions/19011887/how-do-i-run-valgrind-with-an-android-app) and [Two](http://stackoverflow.com/questions/13531496/cant-run-a-java-android-program-with-valgrind/19235439#19235439). But I can't get the log file, it means the log file is not created. Can you share any tips for me? – Jar Jun 23 '14 at 07:45
  • Unfortunately I haven't ever used valgrind on android (valgrind yes, android yes, but not together), so I can't help you past that. – Tassos Bassoukos Jun 23 '14 at 09:09