Dear Salvatore, How can I reproduce your issue?
Thanks, Tim Kourt Intel Open Source Technology Center -----Original Message----- From: salvatore.iovene at gmail.com [mailto:salvatore.iov...@gmail.com] On Behalf Of Salvatore Iovene Sent: Friday, February 5, 2016 3:59 AM To: Kourt, Tim A <tim.a.kourt at intel.com> Cc: iotivity-dev at lists.iotivity.org Subject: Re: [dev] Crash when JNI layer removes OnGetEventListener Hi Tim, my app is already doing that, and after further inspection and placing lots of log prints in various JNI layer files, I came to the conclusion that this is not about accessing an object that lost scope. The crash happens with 100% reproducibility and after a random time since the request to "get". Googling, I've found two interesting resources: https://code.google.com/p/android/issues/detail?id=64947 (but recompiling with gcc 4.9 didn't help me) and especially: https://jira.iotivity.org/browse/IOT-623 That's very similar to my stack trace! Any idea how that was solved? Thanks, Salvatore On Thu, Feb 4, 2016 at 8:40 PM, Kourt, Tim A <tim.a.kourt at intel.com> wrote: > Hi Salvatore, > > Please ensure that your app is doing something along the following lines: > > private List<OcResource> mListOfFoundResources = new > LinkedList<>(); > > @Override > public synchronized void onResourceFound(OcResource ocResource) { > // the following line prevents an object referenced by the ocResource > // from being destroyed after the completion of onResourceFound method > mListOfFoundResources.add(ocResource); > > try { > ocResource.get(new HashMap<String, String>(), this); > ... > > If you didn't find this example useful, please provide the code to replicate > the issue. > > Thanks, > > Tim Kourt > Intel Open Source Technology Center > > > > -----Original Message----- > From: salvatore.iovene at gmail.com [mailto:salvatore.iovene at gmail.com] > On Behalf Of Salvatore Iovene > Sent: Wednesday, February 3, 2016 11:24 PM > To: Kourt, Tim A <tim.a.kourt at intel.com> > Cc: iotivity-dev at lists.iotivity.org > Subject: Re: [dev] Crash when JNI layer removes OnGetEventListener > > Hi Tim, > "someResource" going out of scope and getting GC-ed was exactly what I > thought would be the case, but I made sure that it isn't. I tried making my > OcResource.OnGetListener an object that I know for sure is not going out of > scope, and the issue is still presenting itself. Even forced my program to > wait until onGetCompleted was executed (using a flag and a while loop with a > Thread.sleep) but it's still happening. > > Any other suggestions please? > > > On Wed, Feb 3, 2016 at 9:37 PM, Kourt, Tim A <tim.a.kourt at intel.com> wrote: >> Hi Salvatore, >> >> The sleep command is there for the log readability purposes only and should >> not be used in a real life application. >> >> The symptoms that you described are likely caused by the resource object >> (someResource) going out of scope and GC-ed sometime later. Keeping a global >> reference to the resource should help. >> >> Tim Kourt >> Intel Open Source Technology Center >> >> >> -----Original Message----- >> From: iotivity-dev-bounces at lists.iotivity.org >> [mailto:iotivity-dev-bounces at lists.iotivity.org] On Behalf Of >> Salvatore Iovene >> Sent: Wednesday, February 3, 2016 11:12 AM >> To: iotivity-dev at lists.iotivity.org >> Subject: [dev] Crash when JNI layer removes OnGetEventListener >> >> >>> On 03 Feb 2016, at 14:06, Salvatore Iovene <salvatore at iovene.com> wrote: >>> >>> Hi, >>> I?m working on a project on top of the Iotivity Java API, and when I try do >>> the following, the Iotivity stack crashes: >>> >>> someResource.get(new HashMap<String, String>(), this); >>> >>> Here?s the backtrack but it?s probably not very useful. >>> >>> I/DEBUG ( 2763): pid: 19871, tid: 19928, name: JavaBridge >>> >>> com.example.CordovaPluginOicDemo <<< >>> I/DEBUG ( 2763): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr >>> -------- >>> I/DEBUG ( 2763): eax 00000000 ebx 00004d9f ecx 00004dd8 edx >>> 00000006 >>> I/DEBUG ( 2763): esi db11edb8 edi 00000000 >>> I/DEBUG ( 2763): xcs 00000023 xds 0000002b xes 0000002b xfs >>> 00000117 xss 0000002b >>> I/DEBUG ( 2763): eip f772aec6 ebp 00004dd8 esp db11ec00 flags >>> 00200206 >>> I/DEBUG ( 2763): >>> I/DEBUG ( 2763): backtrace: >>> I/DEBUG ( 2763): #00 pc 00085ec6 /system/lib/libc.so (tgkill+22) >>> I/DEBUG ( 2763): #01 pc 00031223 /system/lib/libc.so >>> (pthread_kill+163) >>> I/DEBUG ( 2763): #02 pc 00032af5 /system/lib/libc.so (raise+37) >>> I/DEBUG ( 2763): #03 pc 0002ac75 /system/lib/libc.so (abort+85) >>> I/DEBUG ( 2763): #04 pc 00050934 >>> /data/app/com.example.CordovaPluginOicDemo-1/lib/x86/libgnustl_shared.so >>> (__gnu_cxx::__verbose_terminate_handler()+452) >>> I/DEBUG ( 2763): #05 pc 0004e3f7 >>> /data/app/com.example.CordovaPluginOicDemo-1/lib/x86/libgnustl_shared.so >>> (__cxxabiv1::__terminate(void (*)())+23) >>> I/DEBUG ( 2763): #06 pc 0004e48f >>> /data/app/com.example.CordovaPluginOicDemo-1/lib/x86/libgnustl_shared.so >>> (std::terminate()+31) >>> I/DEBUG ( 2763): #07 pc 000bcdfd >>> /data/app/com.example.CordovaPluginOicDemo-1/lib/x86/libgnustl_shared.so >>> (execute_native_thread_routine+141) >>> I/DEBUG ( 2763): #08 pc 000301f9 /system/lib/libc.so >>> (__pthread_start(void*)+57) >>> I/DEBUG ( 2763): #09 pc 0002b3da /system/lib/libc.so >>> (__start_thread+26) >>> I/DEBUG ( 2763): #10 pc 00012c56 /system/lib/libc.so >>> (__bionic_clone+70) >>> >>> >>> However, it looks like a threading problem, and I looked at >>> /android/examples/simpleclient/?/SimpleClient.java and right before calling >>> ?get? on a resource, it does ?sleep(1)?. >>> >>> Might the two things be related? ?sleep(1)? just doesn?t sound right? can >>> anyone explain what?s going on and how to address it properly? >> >> Hi again, >> I?ve done some more experimenting, and I?ve come to the conclusion that the >> stack is systematically crashing when the JNI layer removes the >> OnGetListener. >> >> This can always be seen in my logs before the crash: >> >> D/OIC-JNI ( 8643): ~JniOnGetListener >> I/OIC-JNI ( 8643): OnEventListener is removed >> >> Unfortunately there are no more debug logs in that Java file, but given the >> fact that the backtrace mentions ?pthread_kill?, maybe this is related to >> g_jvm->DetachCurrentThread()? >> >> I?m using the Iotivity Java stack in a Cordova plugin for Android, if it >> helps. >> >> Please let me know if you can help! >> Thanks! >> Salvatore >> >> _______________________________________________ >> iotivity-dev mailing list >> iotivity-dev at lists.iotivity.org >> https://lists.iotivity.org/mailman/listinfo/iotivity-dev > > > > -- > Salvatore Iovene > > Personal website: http://iovene.com/ > Founder of AstroBin: http://astrobin.com/ -- Salvatore Iovene Personal website: http://iovene.com/ Founder of AstroBin: http://astrobin.com/