Crash in Android - Signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

I am testing cocos2dx-2.1.4 on a Nexus 7 running Android 4.3. I keep running the app crashing a lot. It doesn’t crash in the iOS version, so I am fairly certain the issues are only related to android. Below are two crash reports that I can’t figure out the problem. Can anyone help? Thanks.

`Signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
Stack frame #00 pc 0001e4e8 /system/lib/libc.so
Stack frame #01 pc 0001c510 /system/lib/libc.so (abort+4)
Stack frame #02 pc 000121d1 /system/lib/libc.so
Stack frame #03 pc 0000e8f5 /system/lib/libc.so
Stack frame #04 pc 0000f7c3 /system/lib/libc.so (dlmalloc+606)
Stack frame #05 pc 00010fff /system/lib/libc.so (dlrealloc+130)
Stack frame #06 pc 0000d9e7 /system/lib/libc.so (realloc+10)
Stack frame #07 pc 0001e709 /system/lib/libbinder.so (android::Parcel::continueWrite(unsigned int)+304)
Stack frame #08 pc 0001e7e3 /system/lib/libbinder.so (android::Parcel::writeInplace(unsigned int)+70)
Stack frame #09 pc 0001f089 /system/lib/libbinder.so (android::Parcel::writeString16(unsigned short const*, unsigned int)+44)
Stack frame #10 pc 00022bf7 /system/lib/libgui.so
Stack frame #11 pc 00026665 /system/lib/libgui.so (android::Surface::dequeueBuffer(ANativeWindowBuffer**, int*)+92)
Stack frame #12 pc 000269b1 /system/lib/libgui.so (android::Surface::hook_dequeueBuffer_DEPRECATED(ANativeWindow*, ANativeWindowBuffer**)+32)
Stack frame #13 pc 00001195 /system/lib/libnvwsi.so
Stack frame #14 pc 00002249 /system/lib/libnvwsi.so
Stack frame #15 pc 0000b545 /system/lib/egl/libEGL_tegra.so
Stack frame #16 pc 0000b7a1 /system/lib/egl/libEGL_tegra.so
Stack frame #17 pc 0000592b /system/lib/egl/libEGL_tegra.so
Stack frame #18 pc 0000a348 /system/lib/egl/libGLESv2_tegra.so
Stack frame #19 pc 000088a0 /system/lib/egl/libGLESv2_tegra.so
Stack frame #20 pc 00008c94 /system/lib/egl/libGLESv2_tegra.so
Stack frame #21 pc 0000fbf8 /system/lib/egl/libGLESv2_tegra.so (glClear+140)
Stack frame #22 pc 001faa3d /data/app-lib/COM.MYPACKAGE/libgame.so (cocos2d::CCDirector::drawScene()+32): Routine drawScene in /PATH/TO/PROJECT/proj.android/…/libs/cocos2dx/CCDirector.cpp:259
Stack frame #23 pc 001faac9 /data/app-lib/COM.MYPACKAGE/libgame.so (cocos2d::CCDisplayLinkDirector::mainLoop()+32): Routine mainLoop in /PATH/TO/PROJECT/proj.android/…/libs/cocos2dx/CCDirector.cpp:1052
Stack frame #24 pc 0021c0a7 /data/app-lib/COM.MYPACKAGE/libgame.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender+10): Routine Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender in /PATH/TO/PROJECT/proj.android/…/libs/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp:14
Stack frame #25 pc 0001dc4c /system/lib/libdvm.so (dvmPlatformInvoke+112)
Stack frame #26 pc 0004decf /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
Stack frame #27 pc 00000214 /dev/ashmem/dalvik-jit-code-cache (deleted)

Build fingerprint: ‘google/nakasi/grouper:4.3/JWR66Y/776638:user/release-keys’
pid: 12312, tid: 12330, name: Thread-3879 >>> COM.MYPACKAGE <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
Stack frame #00 pc 0001e4e8 /system/lib/libc.so
Stack frame #01 pc 0001c510 /system/lib/libc.so (abort+4)
Stack frame #02 pc 000121d1 /system/lib/libc.so
Stack frame #03 pc 0000e8f5 /system/lib/libc.so
Stack frame #04 pc 0000f7c3 /system/lib/libc.so (dlmalloc+606)
Stack frame #05 pc 00010fff /system/lib/libc.so (dlrealloc+130)
Stack frame #06 pc 0000d9e7 /system/lib/libc.so (realloc+10)
Stack frame #07 pc 0001e709 /system/lib/libbinder.so (android::Parcel::continueWrite(unsigned int)+304)
Stack frame #08 pc 0001e7e3 /system/lib/libbinder.so (android::Parcel::writeInplace(unsigned int)+70)
Stack frame #09 pc 0001f089 /system/lib/libbinder.so (android::Parcel::writeString16(unsigned short const*, unsigned int)+44)
Stack frame #10 pc 000468a7 /system/lib/libmedia.so
Stack frame #11 pc 0004ec71 /system/lib/libmedia.so (android::AudioSystem::acquireAudioSessionId(int)+20)
Stack frame #12 pc 000459d1 /system/lib/libmedia.so (android::AudioTrack::set(audio_stream_type_t, unsigned int, audio_format_t, unsigned int, int, audio_output_flags_t, void ()(int, void, void*), void*, int, android::spandroid::IMemory const&, bool, int)+568)
Stack frame #13 pc 00045c45 /system/lib/libmedia.so (android::AudioTrack::AudioTrack(audio_stream_type_t, unsigned int, audio_format_t, unsigned int, int, audio_output_flags_t, void ()(int, void, void*), void*, int, int)+128)
Stack frame #14 pc 00061f45 /system/lib/libmedia.so (android::SoundChannel::play(android::spandroid::Sample const&, int, float, float, int, int, float)+344)
Stack frame #15 pc 000621e9 /system/lib/libmedia.so (android::SoundPool::play(int, float, float, int, int, float)+140)
Stack frame #16 pc 0001dc4c /system/lib/libdvm.so (dvmPlatformInvoke+112)
Stack frame #17 pc 0004decf /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
Stack frame #18 pc 00027060 /system/lib/libdvm.so
Stack frame #19 pc 0002b5ec /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
Stack frame #20 pc 0005ff21 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
Stack frame #21 pc 00049de7 /system/lib/libdvm.so
Stack frame #22 pc 0017b547 /data/app-lib/COM.MYPACKAGE/libgame.so (_JNIEnv::CallStaticIntMethod(_jclass*, _jmethodID*, …)+18): Routine CallStaticIntMethod in (null):0
Stack frame #23 pc 0023632d /data/app-lib/COM.MYPACKAGE/libgame.so (playEffectJNI+52): Routine playEffectJNI in /PATH/TO/PROJECT/proj.android/…/libs/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp:266
Stack frame #24 pc 00235dff /data/app-lib/COM.MYPACKAGE/libgame.so (CocosDenshion::SimpleAudioEngine::playEffect(char const*, bool)+38): Routine playEffect in /PATH/TO/PROJECT/proj.android/…/libs/CocosDenshion/android/SimpleAudioEngine.cpp:208
Stack frame #25 pc 0015cbdf /data/app-lib/COM.MYPACKAGE/libgame.so (PlayLayer::beginCollisionBetweenTruckAndNewCargo(LHContactInfo*)+214): Routine playEffect in jni/…/…/Classes/PlayLayer.cpp:727
Stack frame #26 pc 0016f623 /data/app-lib/COM.MYPACKAGE/libgame.so (LHContactNodeInfo::callListenerWithBodyA(b2Body*, b2Body*, b2Fixture*, b2Fixture*, b2Contact*, int, b2Manifold const*, b2ContactImpulse const*)+58): Routine callListenerWithBodyA in jni/…/…/libs/LevelHelper/Nodes/LHContactNode.cpp:88
Stack frame #27 pc 0016f975 /data/app-lib/COM.MYPACKAGE/libgame.so (LHContactNode::beginEndSolve(b2Contact*, bool)+184): Routine beginEndSolve in jni/…/…/libs/LevelHelper/Nodes/LHContactNode.cpp:362
Stack frame #28 pc 0016f97f /data/app-lib/COM.MYPACKAGE/libgame.so (lhContact_CallBeginEndSolveMethod(void*, b2Contact*, bool)+2): Routine lhContact_CallBeginEndSolveMethod in jni/…/…/libs/LevelHelper/Nodes/LHContactNode.cpp:98
Stack frame #29 pc 0016f453 /data/app-lib/COM.MYPACKAGE/libgame.so (LHContactListener::BeginContact(b2Contact*)+10): Routine BeginContact in jni/…/…/libs/LevelHelper/Nodes/LHContactListener.cpp:12
Stack frame #30 pc 002f0751 /data/app-lib/COM.MYPACKAGE/libgame.so (b2Contact::Update(b2ContactListener*)+280): Routine Update in /PATH/TO/PROJECT/proj.android/…/libs/Box2D/Dynamics/Contacts/b2Contact.cpp:233
Stack frame #31 pc 002fc9f7 /data/app-lib/COM.MYPACKAGE/libgame.so (b2ContactManager::Collide()+176): Routine Collide in /PATH/TO/PROJECT/proj.android/…/libs/Box2D/…/Box2D/Dynamics/Contacts/b2Contact.h:258`

The first one is a OpenGL crash, can you check if you have like very big textures.
The second one is looks like a sound crash.

I would try to isolate the problem and try to find which resource caused the crash.

`Matt Johnston

Does the app crashed when running?
Have you tried TestCpp@ orHelloCpp`?

As i know,where is a good way to find the crash call stack.It is hard to say in a few words.you just google ndk-stack,or you can email me:blue-1986@hotmail.com.

I used ndk-stack to get the crash logs I previously posted.

I am starting to think that it is a memory issue somewhere. I’ve seen some other errors like:

E/AudioFlinger﹕ not enough memory for AudioTrack size=436816

I have tried to read through all the cocos2dx memory documentation. Since I am using autorelease objects, how can I force some of these objects to be released to free up memory instead of waiting for the AutoReleasePool to execute?

You can invoke

PoolManager::sharedPoolManager()->pop();

I am using CocosBuilder for all my scenes. I have read that there are a lot of memory leaks in CCBReader and that nodes loaded from CCBReader are never dealloc. This would explain why I am having memory problems.

Does anyone know if the CCBReader code has been updated lately or way to force release a node loaded from CCBReader?