• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Malloc debug on Android Nougat doesnt work for my Native code

dilsesri

Lurker
Hello All,
I am trying to find memory leaks and corruptions in my native code, which is part of a sample java app. Since the procedure for using malloc debug has been updated from Nougat onwards (ref: Malloc Debug for Android N https://android.googlesource.com/platform/bionic/+/master/libc/malloc_debug/README.md), I have followed the steps in that page to set the options of my interest.

Fortunately, I was able to get the mem corruption detection work (by use of guard option) for a simple buffer overflow in my native code. But, whatever option I use, I couldn't get the leaks detected.

I tried these options:

adb shell setprop libc.debug.malloc.options backtrace

adb shell setprop libc.debug.malloc.options leak_track


I also tried a combination of both options. I didnt see any mallocs or leaks present in my code being captured in logcat. In fact, for most devices I see that device is stuck in bootup when 'backtrace' option is set.

However, what I see is in the logs, is apparently false-positives for leaks in lot of other system programs:

12-16 13:05:51.908 8396 8396 E malloc_debug: +++ chmod leaked block of size 152 at 0x7f7de4b0e0 (leak 1 of 19)
...
12-16 13:05:52.156 8423 8423 E malloc_debug: +++ chown leaked block of size 152 at 0x7f8384b0e0 (leak 1 of 26)
...
12-16 13:05:56.533 8845 8845 E malloc_debug: +++ getprop leaked block of size 152 at 0x7fb684b0e0 (leak 1 of 17)
...
12-16 13:07:24.036 12393 12393 E malloc_debug: +++ /system/bin/dex2oat leaked block of size 131072 at 0xeb22c010 (leak 1 of 2452)
...
12-16 13:07:49.192 13734 13734 E malloc_debug: +++ logcat leaked block of size 5176 at 0x7f8dc5f020 (leak 1 of 21)


So, I have two questions in this context:

1. Does my apk need to be in a specific location for backtrace/leak_track to work? Was it ever tested for apks before, at least on N?
2. Do I need to set any other option for leak detection to work?

It looks like Malloc debug on Nougat is not explored much, so I didnt see any results on Google for any known issues or restrictions.

More details on my setup:
- Android Nougat 7.0
- 64 bit chipset
- Java sample app, with native code as shared lib

PS: If this is not the proper place for this post, kindly let me know so that I can move it to appropriate place
 
Your question is quite specialised, and if you've not already done this, I would try posting it on the Stack Overflow site. This would increase your chances of getting a response.
 
Your question is quite specialised, and if you've not already done this, I would try posting it on the Stack Overflow site. This would increase your chances of getting a response.
I have in fact done that already, but would like to see if if AF members can help me out
 
Back
Top Bottom