Yu-Hsin,

If you could guide me through the steps on how to reproduce the issue or even 
share an app that would expose it, I would gladly help you to find the answers.

Meanwhile, please make sure that you run the latest master including this patch 
https://gerrit.iotivity.org/gerrit/#/c/2290/

Thank you,
Tim

From: Hung Yu-Hsin [mailto:[email protected]]
Sent: Thursday, August 27, 2015 8:59 PM
To: Kourt, Tim A; iotivity-dev at lists.iotivity.org
Subject: RE: [dev] Android JNI OnEventListener crash

Hi Tim,

I've tried your patch, unfortunately the client still has crash issue.

However, this time the only error message is "A/libc?s Fatal signal 6 
(SIGABRT), code -6 in tid 11352 (FinalizerDaemon)", without any stack trace and 
JNI exception details. Do you have any idea about this kind of message?

Also I'm curious about why simply set weak reference to a nullptr can solve 
this issue? When the object is released, the weak reference is supposed to 
reference to a null pointer, and I also tried using IsSameObject to verify it. 
However, the operation is aborted by ART runtime.



Best Regard,

===
Yu-Hsin Hung,
Intern, Mediatek
Graduate Student, Institute of Computer Science and Engineering,
National Chiao-Tung Universiry, Hsinchu 300, Taiwan
(Phone) +886911012113
(Email) hungys at hotmail.com<mailto:hungys at hotmail.com>
(LinkedIn) https://www.linkedin.com/in/hungys
===

________________________________
From: tim.a.kourt at intel.com<mailto:[email protected]>
To: hungys at hotmail.com<mailto:hungys at hotmail.com>; iotivity-dev at 
lists.iotivity.org<mailto:iotivity-dev at lists.iotivity.org>
Subject: RE: [dev] Android JNI OnEventListener crash
Date: Thu, 27 Aug 2015 21:56:32 +0000
Hi Yu-Hsin,

The most probable cause of this crash is OcResource object going out of scope 
before all of the GET responses have been received by a client side. This patch 
should help to make things a bit more robust: 
https://gerrit.iotivity.org/gerrit/#/c/2306/

In general, I would recommend using ??observe?? capability instead of the 
constant polling, unless your server doesn??t support it.

Thanks,
Tim


From: iotivity-dev-bounces at lists.iotivity.org<mailto:iotivity-dev-bounces at 
lists.iotivity.org> [mailto:[email protected]] On Behalf 
Of Yu-Hsin Hung
Sent: Tuesday, August 18, 2015 6:57 AM
To: iotivity-dev at lists.iotivity.org<mailto:iotivity-dev at 
lists.iotivity.org>
Subject: [dev] Android JNI OnEventListener crash

Dear devs,

Recently I found that when Android client sends GET request to server 
frequently (e.g. polling), there will be random crashes due to JNI level being 
aborted. The exception basically says the native code try to access deleted 
weak global reference.

After tracing the implementation, I found that the event listener for 
GET/POST/PUT/?? is stored as weak global references, which means they may be 
released by JVM GC on demand and then cause the crashes.

iotivity<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747>/android<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android>/android_api<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api>/base<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api/base>/jni<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api/base/jni>/JniOnGetListener.cpp
jobject jListener = env->NewLocalRef(m_jwListener);

In the above code, the m_jwListener is a weak global reference, so it may be 
deleted by GC before this line called. But it seems the ART runtime didn??t 
return NULL as expected, but aborting the execution.

Even if I try to modify them as global reference using NewGlobalRef at the 
constructer of JniOnGetListener (as following), sometimes the crash still 
occurs.

iotivity<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747>/android<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android>/android_api<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api>/base<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api/base>/jni<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api/base/jni>/JniOnGetListener.h
jweak m_jwListener;

iotivity<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747>/android<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android>/android_api<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api>/base<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api/base>/jni<https://github.com/iotivity/iotivity/tree/8c044c478ccafb2faccbff398db02f79e4f58747/android/android_api/base/jni>/JniOnGetListener.cpp
m_jwListener = env->NewWeakGlobalRef(jListener);


The error log is attached.
Does anyone notice this issue? or any idea to fix it? Thanks!



Best Regard,

===
Yu-Hsin Hung,
Intern, Mediatek
Graduate Student, Institute of Computer Science and Engineering,
National Chiao-Tung Universiry, Hsinchu 300, Taiwan
(Phone) +886911012113
(Email) hungys at hotmail.com<mailto:hungys at hotmail.com>
(LinkedIn) https://www.linkedin.com/in/hungys
===
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20150828/b8b1c2f4/attachment.html>

Reply via email to