java - Where is my JNIEnv pointer going? -


all,

i'm having hard time c++ jni code. have long-running thread handles pushing stuff other parts of our system java component.

here's code... thread "handleupdatenotification", , can see call function necessary java references...

static void getjavastuff(javavm*& jvmp, jnienv*& env){     jint nsize =1;     jint nvms;     jint nstatus = jni_getcreatedjavavms(&jvmp, nsize, &nvms);      if(nstatus == 0){       nstatus = jvmp->attachcurrentthread((void**) &env, null);       if(nstatus != 0){           //throw error       }     } }  static int handleupdatenotification(void *param) {    javavm* jvmp = null;    jnienv *env = null;    getjavastuff(jvmp, env);    while(true){       //why env null here?       if(env == null)           getjavastuff(jvmp, env);         //do stuff env pointer stuff other parts        //of system, never set env   }   jvmp->detachcurrentthread();   return 0; } 

as can see, have check in loop see if env has been set null. because found after running several hours, env of sudden set null, caused segfaults when tried using later in thread (referencing null pointer) , crash vm. so, added check , re-aquire everything. problem hasn't fixed it... now, new pointer, it's bogus... program still segfaults , when analyze core file see indeed cannot access *env pointer.

has experienced , know how combat it?

platform is: java version "1.7.0_25" openjdk runtime environment (icedtea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2) openjdk client vm (build 23.7-b01, mixed mode, sharing)


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -