Bug 42297 - Application crashes in libmonodroid.so
Summary: Application crashes in libmonodroid.so
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 6.1.0 (C7)
Hardware: PC Windows
: High major
Target Milestone: 7.0 (C8)
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-07-01 01:09 UTC by Dmitry
Modified: 2016-11-21 20:59 UTC (History)
2 users (show)

Tags: BZSRC7
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Dmitry 2016-07-01 01:09:58 UTC
# Steps to reproduce

I can't provide simple steps to reproduce that, i use massive async operations that requests data from network and update suggestion's list after data returned. No matter waht I use: async/await technics or Task.Run -> BeginInvoke(). Process crashes after 10-200 request cycles. All code blocks covered with try/catch but no exception thrown in managed part of code.

Also i tried to catch unhandled exception with:
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
              {
                  log.Fatal(e.ExceptionObject);
                  log.Fatal($"Unhandled exception caught: IsTerminating={e.IsTerminating}");
                  Thread.Sleep(5000);
              };

            AndroidEnvironment.UnhandledExceptionRaiser += (s, e) =>
            {
                log.Fatal(e.Exception);
                log.Fatal($"Unhandled exception caught: Handled={e.Handled}");
                Thread.Sleep(5000);
            };

            Java.Lang.Thread.DefaultUncaughtExceptionHandler = this;

but i can't catch any exception in my code.

# Expected behavior
Everyrhing must work fine.

# Actual behavior
Program periodically crashes in part of code that i can't control.

# Supplemental info (logs, images, videos)
i found this log record in android logs
07-01 10:04:54.433 I/DEBUG   (  360): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-01 10:04:54.433 I/DEBUG   (  360): Build fingerprint: 'HONOR/KIW-L21/HNKIW-Q:5.1.1/HONORKIW-L21/C10B130:user/release-keys'
07-01 10:04:54.433 I/DEBUG   (  360): Revision: '0'
07-01 10:04:54.433 I/DEBUG   (  360): ABI: 'arm'
07-01 10:04:54.433 I/DEBUG   (  360): pid: 11288, tid: 11323, name: Thread-1971  >>> com.teleavtomatika.android.udachataxiclientapp <<<
07-01 10:04:54.433 I/DEBUG   (  360): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xc
07-01 10:04:54.463 I/DEBUG   (  360):     r0 04400000  r1 70e7e7e0  r2 00000000  r3 00000000
07-01 10:04:54.463 I/DEBUG   (  360):     r4 00080011  r5 abe666a8  r6 dead4321  r7 70e7e7e0
07-01 10:04:54.463 I/DEBUG   (  360):     r8 71a9872c  r9 00000001  sl 00000000  fp 00000001
07-01 10:04:54.463 I/DEBUG   (  360):     ip f569ac8c  sp dd7ff20c  lr f541933f  pc f5466be2  cpsr 00070030
07-01 10:04:54.463 I/DEBUG   (  360): 
07-01 10:04:54.463 I/DEBUG   (  360): backtrace:
07-01 10:04:54.463 I/DEBUG   (  360):     #00 pc 000bfbe2  /system/lib/libart.so (bool art::mirror::Object::InstanceOf<(art::VerifyObjectFlags)0>(art::mirror::Class*)+17)
07-01 10:04:54.463 I/DEBUG   (  360):     #01 pc 0007233b  /system/lib/libart.so (art::CheckMethodArguments(art::mirror::ArtMethod*, unsigned int*)+386)
07-01 10:04:54.463 I/DEBUG   (  360):     #02 pc 00217847  /system/lib/libart.so (art::InvokeWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, art::mirror::Object*, _jmethodID*, jvalue*)+386)
07-01 10:04:54.463 I/DEBUG   (  360):     #03 pc 001aa22b  /system/lib/libart.so (art::JNI::CallNonvirtualVoidMethodA(_JNIEnv*, _jobject*, _jclass*, _jmethodID*, jvalue*)+290)
07-01 10:04:54.463 I/DEBUG   (  360):     #04 pc 000baf5f  /system/lib/libart.so (art::CheckJNI::CallNonvirtualVoidMethodA(_JNIEnv*, _jobject*, _jclass*, _jmethodID*, jvalue*)+98)
07-01 10:04:54.463 I/DEBUG   (  360):     #05 pc 0000ae00  /data/app/com.teleavtomatika.android.udachataxiclientapp-1/lib/arm/libmonodroid.so (java_interop_jnienv_call_nonvirtual_void_method_a+72)

# Test environment (full version information)
device: HONOR/KIW-L21/HNKIW-Q:5.1.1/HONORKIW-L21/C10B130:user/release-keys

I use latest release of Xamarin
Xamarin 4.1.1.3 (34a92cd)
Xamarin.Android 6.1.1.1 (7db2aac)
Project libraries and versions: https://s32.postimg.org/hc5ze4r9h/01_07.png
Comment 1 Dmitry 2016-07-01 01:24:39 UTC
found some intresting records before submitted trace:

07-01 10:04:54.273 E/art     (11288): JNI ERROR (app bug): accessed deleted global reference 0x20117e
07-01 10:04:54.273 E/mono-rt (11288): Stacktrace:
07-01 10:04:54.273 E/mono-rt (11288): 
07-01 10:04:54.273 E/mono-rt (11288): 
07-01 10:04:54.273 E/mono-rt (11288): Attempting native Android stacktrace:
07-01 10:04:54.273 E/mono-rt (11288): 
07-01 10:04:54.283 E/mono-rt (11288):  at ???+0 [0x70e7e7e0]
07-01 10:04:54.333 E/mono-rt (11288):  at ???+0 [0xdead431f]
07-01 10:04:54.333 E/mono-rt (11288): 
07-01 10:04:54.333 E/mono-rt (11288): =================================================================
07-01 10:04:54.333 E/mono-rt (11288): Got a SIGSEGV while executing native code. This usually indicates
07-01 10:04:54.333 E/mono-rt (11288): a fatal error in the mono runtime or one of the native libraries 
07-01 10:04:54.333 E/mono-rt (11288): used by your application.
07-01 10:04:54.333 E/mono-rt (11288): =================================================================
07-01 10:04:54.333 E/mono-rt (11288): 
07-01 10:04:54.333 F/libc    (11288): Fatal signal 11 (SIGSEGV), code 1, fault addr 0xc in tid 11323 (Thread-1971)


it seems like this bug is related to mine: https://bugzilla.xamarin.com/show_bug.cgi?id=38012
Comment 2 Jonathan Pryor 2016-07-01 01:26:23 UTC
Could you please provide a repro?

Your Project Libraries and Versions screenshot is odd: it states Mono.Android.dll 6.0.5.177512507; git-rev-head:a94a03b; git-branch:HEAD

This corresponds to Xamarin.Android 6.0.3, while you state that you're using the "latest release" of 6.1.1.1.

I find this very confusing.

Additionally, the native stack trace provides no context; *why* did a JNIEnv::CallNonvirtualVoidMethod() invocation cause a SIGSEGV? I don't know. *Normally* such messages would be printed to logcat earlier, before the Build fingerprint information (often due to using an invalid GREF, but there could be numerous reasons).
Comment 3 Jonathan Pryor 2016-07-01 01:32:35 UTC
Bug #38012 does look similar. Bug #38012 is not fixed in Xamarin.Android 6.0.3 (the version from the screenshot), but should fixed in Xamarin.Android 6.0.4 and 6.1.
Comment 4 Dmitry 2016-07-01 02:59:18 UTC
Thank you for your notice. I made screenshot with wrong list of assemblies. Actually i should compile in release than unpack exported assemblies and make screenshot.

So, for now i resolved my problem with:

I changed TargetFramework 5.0 to 6.0, remove massive parallelism (remain only one concurrent thread, that request sequential queries to network server) and crashes are gone away.

Also i removed all Xamarin.* packages from android device ang give VS ability to reinstall newer dependecies.

Maybe this helps some one.