ABORTION: CORRUPTION OF BLOOD BLOOD ON NDK. (POCO library, Sqlite3, Cocos2dx)

I ran into the 'ABORTING: HEAP MEMORY CORRUPTION' on Android NDK .

If I return with ndk-gdb , it mostly occurs in malloc/dlfree in libc.so and after long hours of tracking the problem, this happens mainly inside calls to sqlite3_xxx functions that fully work on iOS env.

I just can't find where I need to go deeper.

Has anyone encountered a similar problem and fixed it?

+4
source share
2 answers
  • I saw memory issues, but not the 'ABORTING: HEAP MEMORY CORRUPTION' that you are reporting.

  • You need to find out which heap is damaged: one Java or C / C ++. Or it could be your sql. If the log is not informative, you can try to find the error message in binary files.

  • If this is a bunch of C / C ++, then for me the replacement of the standard version of malloc / calloc / free by my versions worked.

     #define malloc(x) myMalloc(x, __FILE__,__LINE__,__func__) 

    etc.; myMalloc () and friends print debugging information so you can find out where the memory was allocated and freed. I had a library source and I could compile it. Then do registration, logging, logging ...

     #include <android/log.h> #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , "~~~~~~", __VA_ARGS__) #define DLOG(...) __android_log_print(ANDROID_LOG_DEBUG , "~~~~~~", __VA_ARGS__) 

    I also made myMalloc () zero allocated memory - just in case. Another trick is to isolate a larger cartridge and put a protective value at the end. If this value becomes damaged - you see.

  • If this is a bunch of Java, you will have to write down your own function calls (I myself have never seen problems in the Java heap, usually Java complains about JNI-specific elements).

+3
source

In my program, "ABORTING: HEAT MEMORY CORRUPTION" shows when there are thread safety issues. In particular, with the Cocos2d-x getFileData() ZipUtils can be damaged when loading the atlas .plist and addImageAsync() at the same time on Android. Although the codes work fine on iOS.

+3
source

All Articles