Thanks Tim,
I think that the stack crashing with an obscure message, even if the
API was used improperly, is less than ideal.

I would recommend the throwing of an exception if the "get" method is
used on a device or platform resource.

  Salvatore


On Thu, Feb 25, 2016 at 9:47 PM, Kourt, Tim A <tim.a.kourt at intel.com> wrote:
> Hi Salvatore,
>
> Please note, platform and device info should not be discovered through the 
> OcResource's "get" method. There are two specific APIs that were designed for 
> these purposes: OcPlatform.getPlatformInfo(...) and 
> OcPlatform.getDeviceInfo(...)
>
> Sample queries:
>
> OcPlatform.getPlatformInfo("",
>                     OcPlatform.WELL_KNOWN_PLATFORM_QUERY,
>                     EnumSet.of(OcConnectivityType.CT_DEFAULT),
>                     this);
>
> OcPlatform.getDeviceInfo("",
>                     OcPlatform.WELL_KNOWN_DEVICE_QUERY,
>                     EnumSet.of(OcConnectivityType.CT_DEFAULT),
>                     this);
>
> Please refer to the DeviceDiscoveryClient/ DeviceDiscoveryServer examples for 
> more details.
>
> Regards,
>
> Tim Kourt
> Intel Open Source Technology Center
>
>
> -----Original Message-----
> From: Iovene, Salvatore [mailto:salvatore.iovene at intel.com]
> Sent: Thursday, February 25, 2016 5:13 AM
> To: iotivity-dev at lists.iotivity.org
> Cc: Kourt, Tim A <tim.a.kourt at intel.com>
> Subject: Re: [dev] Crash when JNI layer removes OnGetEventListener
>
> Hi all,
> I thought I'd share some progress.
>
> I've discovered that what makes the stack crash is performing a get on an 
> OcResource with URI /oic/d.
>
> /oic/p is fine, and so is any other resource.
>
> This has got nothing to do with listeners, how many I have, etc. I've tried 
> with multiple resources on the same or multiple server, and my app works fine.
>
> But performing a get on an /oic/d resource will crash it every single time.
>
> Would you say this might a bug in the Iotivity stack?
>
>   Salvatore
>
>
> On Mon, Feb 22, 2016 at 10:06 AM, Iovene, Salvatore <salvatore.iovene at 
> intel.com> wrote:
>> Hi all,
>> after unsuccesful attempts at debugging this crash, I thought I'd try
>> on a different device and architecture, because perhaps it's an issue
>> at some lower level.
>>
>> Lo and behold, when I compiled Iotivity for armeabi-v7a (using the
>> same flags) and installed my Cordova/Android app on an Android 5.0 arm
>> device, the crash is gone.
>>
>> But alas, now my callback to `OcResource.get` is never called, as if
>> the operation never completes.
>>
>> `adb logcat` shows:
>>
>> D/OIC-JNI (18275): OcResource_get
>> D/OIC-JNI (18275): OnEventListener: new listener
>>
>> and then it's waiting forever. I have a loop that waits until the
>> OcResource.OnGetListener.OnGetCompleted (or OnGetFailed) is called,
>> using Thread.sleep.
>>
>> What might cause OcResource.get to never execute the callback?
>>
>> TIA,
>>   Salvatore
>>
>>
>> On Wed, Feb 3, 2016 at 9:11 PM, Salvatore Iovene <salvatore at iovene.com> 
>> wrote:
>>>
>>>> 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 <salvatore.iovene at intel.com> Linux Software Engineer
>> Intel Open Source Technology Center, Finland
>> Tel.: +358504804026
>
>
>
> --
> Salvatore Iovene <salvatore.iovene at intel.com>
> Linux Software Engineer
> Intel Open Source Technology Center, Finland
> Tel.: +358504804026



-- 
Salvatore Iovene <salvatore.iovene at intel.com>
Linux Software Engineer
Intel Open Source Technology Center, Finland
Tel.: +358504804026

Reply via email to