App random crash: JNI ERROR (app bug): accessed deleted global reference

Our customer is experiencing random app crashes. Our app is developed in Xamarin.Forms running only in Android devices (that's why i post this here). We retrieved our customer's devices in order to get any further info from our app logs + logcat. Digging into those logs, we can see the real cause of the application quitting abruptly. For any reason, the process of our app dies because of a SIGABRT signal, as we can see here:

D/dalvikvm( 4460): GC_EXPLICIT freed 4069K, 31% free 21542K/31192K, paused 3ms+9ms, total 45ms
I/dalvikvm( 4460): JNI ERROR (app bug): accessed deleted global reference 0x20701a0a
E/dalvikvm( 4460): VM aborting
F/libc    ( 4460): Fatal signal 6 (SIGABRT) at 0x0000116c (code=-6), thread 8100 (com.company.app)
I/DEBUG   (  251): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  251): Build fingerprint: 'Honeywell/helsinki/CT50LFN-CS13S:4.4.4/KTU84P/59.02.03.0033:user/release-keys'
I/DEBUG   (  251): Revision: '0'
I/DEBUG   (  251): pid: 4460, tid: 8100, name: com.company.app  >>> com.company.app <<<
I/DEBUG   (  251): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------

Doing some research i've found several links where people had similar problems:

mono-for-android.1047100.n5.nabble.com/jni-error-with-4-2-4-on-jellybean-td5711456.html
https://bugzilla.xamarin.com/show_bug.cgi?id=39654

Following the guidance made by @JonathanPryor on those 2 links, i enabled GREF logging on the device using:

adb shell setprop debug.mono.log gref-

while testing our app, but i've encountered with 2 major drawbacks: The app runs reeealy slow, and i think that because of this i can't reproduce this SIGABRT. And finally, the Global Reference Messages displayed into LogCat doesn't display the stacktrace where the references are made, eg

I/monodroid-gref(27342): +g+ grefc 252 gwrefc 0 obj-handle 0xe4300021/L -> new-handle 0x1d3008c6/G from thread '(null)'(1)

and given that scenario, i can't determine if a reference is being disposed on my codebase explicitly or anything else.

Another pattern found in the logs received, is that before those SIGABRT crashes there are GC logs present, sometimes strictly before the "Fatal signal 6" message (such as the one shown here), and sometimes a bit more early. Those GC logs vary from GC_EXPLICIT to GC_CONCURRENT.

At this time me and my team can't find any direct solution applicable to our code. Is there any further help avialable about this issue? do we have to wait for a Xamarin update in order to get this issue resolved? Why does the GREF messages doesn't display the adequate stacktrace?

Best Answer

  • AndresBlasPujadasAndresBlasPujadas US ✭✭
    Accepted Answer

    UPDATE:
    We've updated to the latest release of Xamarin.Forms and tested our app. We could not reproduce any crashes so far. So, we hope that this issue was related to the previous version of Forms we were using. Fingers crossed :)

Answers

  • AndresBlasPujadasAndresBlasPujadas USMember ✭✭

    Forgot to post Version info:

    Microsoft Visual Studio Professional 2013
    Version 12.0.40629.00 Update 5
    Microsoft .NET Framework
    Version 4.6.01038

    Visual Basic 2013 06177-004-0447006-02202
    Microsoft Visual Basic 2013

    Visual C# 2013 06177-004-0447006-02202
    Microsoft Visual C# 2013

    Visual C++ 2013 06177-004-0447006-02202
    Microsoft Visual C++ 2013

    Xamarin 4.0.1.96 (dcea9c1)
    Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

    Xamarin.Android 6.0.1.10 (e98e962)
    Visual Studio plugin to enable development for Xamarin.Android.

    Xamarin.iOS 9.4.1.24 (47eb74b)
    Visual Studio extension to enable development for Xamarin.iOS.

    Testing out app in Android 4.4.4 KitKat

  • rarenivarrarenivar USMember ✭✭

    I'm experiencing the same issue.
    @AndresBlasPujadas - Have you found a solution for this?

  • AndresBlasPujadasAndresBlasPujadas USMember ✭✭

    @rarenivar i've got nothing but bad news. We're still facing the same problem. Anything you would like to add about it?

  • rarenivarrarenivar USMember ✭✭

    @AndresBlasPujadas - What version of Xamarin.Forms are you running?
    I upgraded to the latest version (2.3.0.49) and I haven't been able to reproduce this bug.

  • AndresBlasPujadasAndresBlasPujadas USMember ✭✭

    @rarenivar
    We were using 2.2.x. Now we're updating Xamarin.Forms to the latest version (2.3.0.49) to solve another issue. But now that you mention that, we will re-test our app in order to reproduce this SIGABRT error. Keep in mind that it was reeealy hard to reproduce this issue, sometimes you may think that the app works perfectly and when you stop working on it, it stabs you in the back :(

  • AndresBlasPujadasAndresBlasPujadas USMember ✭✭
    Accepted Answer

    UPDATE:
    We've updated to the latest release of Xamarin.Forms and tested our app. We could not reproduce any crashes so far. So, we hope that this issue was related to the previous version of Forms we were using. Fingers crossed :)

Sign In or Register to comment.