1

When I write C++ with MS Visual Studio, I use the following statement to check my heap for corruptions. This has been an excellent tool in homing in on problems:

_ASSERTE( _CrtCheckMemory() );

Basically you can scatter the above statement around your code to check the consistency of the heap.

Is there something similar that can be used in Android NDK programs to identify heap corruption at runtime - before I crash with a tombstone dump?

SparkyNZ
  • 6,266
  • 7
  • 39
  • 80

1 Answers1

1

In Linux, similar functionality can be achieved by mcheck. But, unfortunately, this can't be used on Android (however, here and here can be find mcheck.h for Android)

If your device rooted, you can try this:

For dump analyzation, you can try use deprecated Android Monitor (this link should help to enable native heap dump)

  • For Android is it just a matter of including one of those mcheck.h headers and then it will work? (i.e. do the functions themselves exist in standard NDK runtime libraries?) – SparkyNZ Feb 04 '18 at 22:47
  • 1
    I didn't find any of these functions in current NDK. Also, these links is 6 years old, so I think even binaries with definitions of mcheck's functions for x86/x86_64 (if they exist) can't be used to bring this functionality for modern devices. – Van der Deken Feb 05 '18 at 08:35
  • FYI, root is not needed for ASAN as of NDK r17. – Dan Albert May 14 '18 at 21:16