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-boun...@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

Reply via email to