Very Frustrating JniHelper Crash


I am getting the following crash on app load:

********** Crash dump: ********** Build fingerprint: 'samsung/SPH-D710VMUB/SPH-D710VMUB:4.1.2/JZO54K/SPH-D710.GB28:user/release-keys' pid: 16609, tid: 16609, name: cos2dx.hellocpp >>> org.cocos2dx.hellocpp <<< signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000 Stack frame #00 pc 00192524 /data/data/org.cocos2dx.hellocpp/lib/ (_JavaVM::GetEnv(void**, int)+28): Routine getJNIEnv at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #01 pc 0026eb24 /data/data/org.cocos2dx.hellocpp/lib/ Routine getEnv at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #02 pc 0026ed4c /data/data/org.cocos2dx.hellocpp/lib/ Routine getStaticMethodInfo_ at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #03 pc 0026f118 /data/data/org.cocos2dx.hellocpp/lib/ (cocos2d::JniHelper::getStaticMethodInfo(cocos2d::JniMethodInfo_&, char const*, char const*, char const*)+44): Routine openKeyboardJNI at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #04 pc 0026dcf4 /data/data/org.cocos2dx.hellocpp/lib/ (getBoolForKeyJNI(char const*, bool)+64): Routine getIntegerForKeyJNI(char const*, int) at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #05 pc 00288dc4 /data/data/org.cocos2dx.hellocpp/lib/ (cocos2d::CCUserDefault::getBoolForKey(char const*, bool)+40): Routine cocos2d::CCUserDefault::getFloatForKey(char const*, float) at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #06 pc 00111a7c /data/data/org.cocos2dx.hellocpp/lib/ Routine TGScoreLabel at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #07 pc 00111adc /data/data/org.cocos2dx.hellocpp/lib/ Routine TGScoreLabel at /Users/egjoka/Documents/Projects/jezzball/samples/Cpp/HelloCpp/ Stack frame #08 pc 00003753 /system/bin/linker Stack frame #09 pc 00005c4b /system/bin/linker Stack frame #10 pc 0004f65b /system/lib/ (dvmLoadNativeCode(char const*, Object*, char**)+186) Stack frame #11 pc 000660f5 /system/lib/ Stack frame #12 pc 000273a4 /system/lib/ Stack frame #13 pc 000205b0 [stack]

Any help would be greatly appreciated. I have based the project on samplecpp and in main I have:

jint JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_VERSION_1_2;

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
if (!CCDirector::sharedDirector()->getOpenGLView())
CCEGLView *view = CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_FOREGROUND, NULL);

Thank you guys very much

JNI Multi-threaded Access Problems

um…I guess it may be jni version’s problem, “JNIVERSION12” is a weired macro, what I see in my cocos2d-x version(2.2.2) is like this.
#define JNI_VERSION_1_1 0x00010001
#define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
#define JNI_VERSION_1_6 0x00010006
anyway, check it plz.

Featured Android game crashes in

I’ve tried all the different versions and still no go



Just wanted to confirm that I’m also getting JniHelper crashes. For me it’s on app exit though.
v2.2.1 did not have this problem.



Looking into this some more, it looks like getEnv() was changed in JniHelper.cpp
It seems that getEnv() now sets env as a thread specific variable and no longer supports multi-threaded access to the JNI. My guess is that it’s related to getEnv() using only one key for pthread_setspecific and not accounting for multiple threads calling getEnv(). I’m unfamiliar with pthread_setspecific, so I don’t have any suggestions at the moment other than rolling back to v2.2.1.

Perhaps we should submit this as a bug?


Hi again,

I went ahead and submitted this as a bug: