Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash after startup after upgrade to VS 16.6.0 #4713

Closed
rgroenewoudt opened this issue May 22, 2020 · 15 comments · Fixed by #4725
Closed

Crash after startup after upgrade to VS 16.6.0 #4713

rgroenewoudt opened this issue May 22, 2020 · 15 comments · Fixed by #4725
Assignees
Labels
Area: App Runtime Issues in `libmonodroid.so`.

Comments

@rgroenewoudt
Copy link

rgroenewoudt commented May 22, 2020

Crash immediately after starting after upgrading Visual Studio 2019 to 16.6.0:

W/monodroid-assembly( 6433): typemap: unable to find mapping to a managed type from Java type 'androidx/fragment/app/FragmentManagerImpl'

=================================================================
	Native Crash Reporting
=================================================================
Got a SEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

No native Android stacktrace (see debuggerd output).

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0xccd6c949):0xccd6c939  e8 c2 80 f3 ff 83 c4 10 c7 44 24 20 00 00 00 00  .........D$ ....
0xccd6c949  8b 45 00 8b 40 04 89 44 24 24 83 ec 04 6a 00 8d  .E..@..D$$...j..
0xccd6c959  44 24 18 50 56 e8 ed d0 f3 ff 89 f9 83 c4 10 85  D$.PV...........
0xccd6c969  c0 8b 54 24 40 0f 84 a1 00 00 00 89 34 24 8b 68  ..T$@.......4$.h

=============================================================

====
	Managed Stacktrace:
=================================================================
	  at <unknown> <0xffffffff>
	  at Java.Interop.TypeManager:monodroid_typemap_java_to_managed <0x00012>
	  at Java.Interop.TypeManager:GetJavaToManagedType <0x00063>
	  at Java.Interop.TypeManager:CreateInstance <0x0017f>
	  at Java.Lang.Object:GetObject <0x0014b>
	  at Java.Lang.Object:_GetObject <0x000d7>
	  at Java.Lang.Object:GetObject <0x00063>
	  at AndroidX.Core.App.ComponentActivity:get_Lifecycle <0x00107>
	  at AndroidX.Fragment.App.FragmentActivity:get_Lifecycle <0x0003f>
	  at SequriX.Android.Activities.AppActivity:Fragment.set′ <0x000f8>
	  at SequriX.Android.Activities.AppActivity:set_Fragment″ <0x0009b>
	  at ArxOne.MrAdvice.Advice.InnerMethodContext:Invoke <0x00122>
	  at ArxOne.MrAdvice.Advice.AdviceContext:InvokeNext <0x00051>
	  at ArxOne.MrAdvice.Advice.SyncAdviceContext:Proceed <0x0003f>
	  at SequriX.Shared.Helpers.Attributes.AppUiThreadAttribute:Advise <0x000ea>
	  at ArxOne.MrAdvice.Advice.Method

Version Information

VS2019 16.6.
No issues with 16.5

Project

References in my project:

Calligraphy, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Java.Interop
JetBrains.Annotations, Version=2019.1.3.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL
Microsoft.AppCenter, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL
Microsoft.AppCenter.Analytics, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL
Microsoft.AppCenter.Analytics.Android.Bindings, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL
Microsoft.AppCenter.Android.Bindings, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL
Microsoft.AppCenter.Crashes, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL
Microsoft.AppCenter.Crashes.Android.Bindings, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL
Microsoft.CSharp
Mono.Android
MrAdvice, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c0e7e6eab6f293d8, processorArchitecture=MSIL
Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL
NodaTime, Version=2.4.6.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL
SQLitePCLRaw.core, Version=2.0.2.669, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL
SQLitePCLRaw.lib.e_sqlcipher.android, Version=2.0.2.669, Culture=neutral, PublicKeyToken=cdacefa0eb8d9dac, processorArchitecture=MSIL
SQLitePCLRaw.provider.e_sqlcipher, Version=2.0.2.669, Culture=neutral, PublicKeyToken=c242ffa62330c89b, processorArchitecture=MSIL
System
System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL
System.Core
System.Data
System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL
System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
System.ServiceModel
System.Xml
Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Arch.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Arch.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Support.Collections, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Support.CustomView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Support.VersionedParcelable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.Android.Support.ViewPager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Activity, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Annotation, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Arch.Core.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.AsyncLayoutInflater, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Collection, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.CoordinatorLayout, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.CursorAdapter, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.CustomView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.DocumentFile, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.DrawerLayout, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Fragment, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.GridLayout, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Interpolator, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Legacy.Support.Core.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Legacy.Support.Core.Utils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Lifecycle.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Lifecycle.LiveData.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Lifecycle.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Lifecycle.ViewModel, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Lifecycle.ViewModelSavedState, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Loader, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.LocalBroadcastManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Media, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.MultiDex, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.Print, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.SavedState, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.SlidingPaneLayout, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.SwipeRefreshLayout, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.VectorDrawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.VectorDrawable.Animated, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.VersionedParcelable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.AndroidX.ViewPager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
Xamarin.ANRWatchDog, Version=1.4.25.0, Culture=neutral, processorArchitecture=MSIL
@rgroenewoudt rgroenewoudt added the Area: App Runtime Issues in `libmonodroid.so`. label May 22, 2020
@grendello
Copy link
Contributor

@rgroenewoudt would you be able to create a small sample app which reproduces the issue? I can't diagnose the cause from the information you provided, alas. Thanks!

@grendello grendello added the need-info Issues that need more information from the author. label May 25, 2020
@rgroenewoudt
Copy link
Author

rgroenewoudt commented May 25, 2020

I'm still trying to create a sample app but I found out that I don't have any issues with <AndroidEnablePreloadAssemblies>True</AndroidEnablePreloadAssemblies>

@grendello
Copy link
Contributor

@rgroenewoudt That's interesting... I will certainly need the sample to figure it out, though. Assembly preloading shouldn't have impact on the way typemaps work. What matters is whether it's a Debug or Release build and the actual contents of the type maps. That's why I need the repro.

@rgroenewoudt
Copy link
Author

rgroenewoudt commented May 25, 2020

App3.zip
Sample app attached. The issue happens when AndroidEnablePreloadAssemblies is turned off in combination with AndroidX in a debug build, tested in emulator.

@grendello grendello removed the need-info Issues that need more information from the author. label May 25, 2020
@grendello grendello added this to the Under Consideration milestone May 25, 2020
@rgroenewoudt
Copy link
Author

During debugging I'm also getting messages for various classes from NuGet packages:
W/monodroid-assembly(10427): typemap: unable to find mapping to a managed type from Java type 'uk/co/chrisjenx/calligraphy/CalligraphyLayoutInflater'

@grendello
Copy link
Contributor

@rgroenewoudt These messages are harmless - not all Java types are mapped. The real issue here is a segfault in Mono code, I'm investigating it now.

@grendello
Copy link
Contributor

So, the crash happens because of this line in the Mono runtime. Xamarin.Android runtime uses this code to load a managed type given its name - note that it passes nullptr as the 2nd parameter, which eventually ends up passed to the Mono function mentioned earlier which crashes on the indicated line with:

05-25 14:45:29.392 11029 11029 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
05-25 14:45:29.420 11058 11058 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-25 14:45:29.420  1840  1840 I /system/bin/tombstoned: received crash request for pid 11029
05-25 14:45:29.421 11058 11058 I crash_dump64: performing dump of process 11029 (target tid = 11029)
05-25 14:45:29.427 11058 11058 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-25 14:45:29.427 11058 11058 F DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
05-25 14:45:29.427 11058 11058 F DEBUG   : Revision: '0'
05-25 14:45:29.427 11058 11058 F DEBUG   : ABI: 'x86_64'
05-25 14:45:29.427 11058 11058 F DEBUG   : Timestamp: 2020-05-25 14:45:29+0200
05-25 14:45:29.427 11058 11058 F DEBUG   : pid: 11029, tid: 11029, name: ompanyname.app3  >>> com.companyname.app3 <<<
05-25 14:45:29.427 11058 11058 F DEBUG   : uid: 10134
05-25 14:45:29.427 11058 11058 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
05-25 14:45:29.427 11058 11058 F DEBUG   : Cause: null pointer dereference
05-25 14:45:29.427 11058 11058 F DEBUG   :     rax 000000000000002f  rbx 0000000000000001  rcx 0000000000000000  rdx 0000000000000030
05-25 14:45:29.427 11058 11058 F DEBUG   :     r8  0000000000000003  r9  000000000013e2e2  r10 0173eed800000000  r11 0000000000000206
05-25 14:45:29.427 11058 11058 F DEBUG   :     r12 0000000000000000  r13 00007478530343c0  r14 00007478075eda33  r15 000074780763efb0
05-25 14:45:29.427 11058 11058 F DEBUG   :     rdi 0000000000000000  rsi 00007478e2cb14d0
05-25 14:45:29.427 11058 11058 F DEBUG   :     rbp 00007ffef3a35680  rsp 00007ffef3a355d0  rip 0000747807a4066a
05-25 14:45:29.432  1792  2471 E GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
05-25 14:45:29.432  1792  2471 E GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
05-25 14:45:29.462 11058 11058 F DEBUG   : 
05-25 14:45:29.462 11058 11058 F DEBUG   : backtrace:
05-25 14:45:29.462 11058 11058 F DEBUG   :       #00 pc 00000000003ba66a  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
05-25 14:45:29.462 11058 11058 F DEBUG   :       #01 pc 00000000003ba3d1  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
05-25 14:45:29.462 11058 11058 F DEBUG   :       #02 pc 00000000003ba26d  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
05-25 14:45:29.462 11058 11058 F DEBUG   :       #03 pc 000000000000ddb5  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
05-25 14:45:29.462 11058 11058 F DEBUG   :       #04 pc 000000000000def3  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
05-25 14:45:29.462 11058 11058 F DEBUG   :       #05 pc 0000000000069532  <anonymous:5ad25000>

The fix is simple and I'll be opening a PR against Mono soon. It may take a few days to propagate to Xamarin.Android/master, I'll keep this issue updated.

@grendello
Copy link
Contributor

grendello commented May 25, 2020

@rgroenewoudt PR for mono/master fixing this issue is up mono/mono#19839

grendello added a commit to grendello/xamarin-android that referenced this issue May 26, 2020
Fixes: dotnet#4713
Context: mono/mono@10795da1c065c
Context: mono/mono@8c085a99b32e9

Whenever Xamarin.Android runtime needs to instantiate a managed type, it
first looks it up by calling the following function:

    MonoType *type = mono_reflection_type_from_name ("MyType, Assembly", nullptr);

The `nullptr` pointer refers to an instance of the Mono `MonoImage`
structure and if `null`, it should cause Mono to find the correct image
containing the type and load it, if not already loaded.

The pointer is propagated down the call chain inside Mono and due to one
of the functions called not properly validating its arguments, the
`null` pointer was dereferenced, leading to a crash similar to:

    libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
    crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
    /system/bin/tombstoned: received crash request for pid 11029
    crash_dump64: performing dump of process 11029 (target tid = 11029)
    DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
    DEBUG   : Revision: '0'
    DEBUG   : ABI: 'x86_64'
    DEBUG   : Timestamp: 2020-05-25 14:45:29+0200
    DEBUG   : pid: 11029, tid: 11029, name: ompanyname.app3  >>> com.companyname.app3 <<<
    DEBUG   : uid: 10134
    DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
    DEBUG   : Cause: null pointer dereference
    DEBUG   :     rax 000000000000002f  rbx 0000000000000001  rcx 0000000000000000  rdx 0000000000000030
    DEBUG   :     r8  0000000000000003  r9  000000000013e2e2  r10 0173eed800000000  r11 0000000000000206
    DEBUG   :     r12 0000000000000000  r13 00007478530343c0  r14 00007478075eda33  r15 000074780763efb0
    DEBUG   :     rdi 0000000000000000  rsi 00007478e2cb14d0
    DEBUG   :     rbp 00007ffef3a35680  rsp 00007ffef3a355d0  rip 0000747807a4066a
    DEBUG   :
    DEBUG   : backtrace:
    DEBUG   :       #00 pc 00000000003ba66a  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
    DEBUG   :       #1 pc 00000000003ba3d1  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
    DEBUG   :       #2 pc 00000000003ba26d  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
    DEBUG   :       #3 pc 000000000000ddb5  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
    DEBUG   :       dotnet#4 pc 000000000000def3  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
    DEBUG   :       dotnet#5 pc 0000000000069532  <anonymous:5ad25000>

Mono commit mono/mono@10795da1c06 fixes this issue.

Other changes:

 * mono/mono@89d772a3abb Always include Unicode charinfo, so tar made in csc mode works in mcs mode (#19813)
 * mono/mono@e9d3af508e4 Bump bockbuild to get mono/bockbuild#159
 * mono/mono@d6f0c25d34d [2020-02] Bump msbuild to track mono-2019-12 (#19661)
@grendello grendello mentioned this issue May 26, 2020
grendello added a commit to grendello/xamarin-android that referenced this issue May 27, 2020
Fixes: dotnet#4713
Context: mono/mono@10795da1c065c
Context: mono/mono@8c085a99b32e9

Whenever Xamarin.Android runtime needs to instantiate a managed type, it
first looks it up by calling the following function:

    MonoType *type = mono_reflection_type_from_name ("MyType, Assembly", nullptr);

The `nullptr` pointer refers to an instance of the Mono `MonoImage`
structure and if `null`, it should cause Mono to find the correct image
containing the type and load it, if not already loaded.

The pointer is propagated down the call chain inside Mono and due to one
of the functions called not properly validating its arguments, the
`null` pointer was dereferenced, leading to a crash similar to:

    libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
    crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
    /system/bin/tombstoned: received crash request for pid 11029
    crash_dump64: performing dump of process 11029 (target tid = 11029)
    DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
    DEBUG   : Revision: '0'
    DEBUG   : ABI: 'x86_64'
    DEBUG   : Timestamp: 2020-05-25 14:45:29+0200
    DEBUG   : pid: 11029, tid: 11029, name: ompanyname.app3  >>> com.companyname.app3 <<<
    DEBUG   : uid: 10134
    DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
    DEBUG   : Cause: null pointer dereference
    DEBUG   :     rax 000000000000002f  rbx 0000000000000001  rcx 0000000000000000  rdx 0000000000000030
    DEBUG   :     r8  0000000000000003  r9  000000000013e2e2  r10 0173eed800000000  r11 0000000000000206
    DEBUG   :     r12 0000000000000000  r13 00007478530343c0  r14 00007478075eda33  r15 000074780763efb0
    DEBUG   :     rdi 0000000000000000  rsi 00007478e2cb14d0
    DEBUG   :     rbp 00007ffef3a35680  rsp 00007ffef3a355d0  rip 0000747807a4066a
    DEBUG   :
    DEBUG   : backtrace:
    DEBUG   :       #00 pc 00000000003ba66a  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
    DEBUG   :       #1 pc 00000000003ba3d1  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
    DEBUG   :       #2 pc 00000000003ba26d  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
    DEBUG   :       #3 pc 000000000000ddb5  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
    DEBUG   :       dotnet#4 pc 000000000000def3  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
    DEBUG   :       dotnet#5 pc 0000000000069532  <anonymous:5ad25000>

Mono commit mono/mono@10795da1c06 fixes this issue.

Other changes:

 * mono/mono@89d772a3abb Always include Unicode charinfo, so tar made in csc mode works in mcs mode (#19813)
 * mono/mono@e9d3af508e4 Bump bockbuild to get mono/bockbuild#159
 * mono/mono@d6f0c25d34d [2020-02] Bump msbuild to track mono-2019-12 (#19661)
jonpryor pushed a commit that referenced this issue May 27, 2020
Fixes: #4713

Context: mono/mono@10795da1c065c
Context: mono/mono@8c085a99b32e9

Changes: mono/mono@075c3f0...8c085a9

  * mono/mono@8c085a99b32: [reflection] Check whether a pointer is valid before dereferencing (#19842)
  * mono/mono@89d772a3abb: Always include Unicode charinfo, so tar made in csc mode works in mcs mode (#19813)
  * mono/mono@e9d3af508e4: Bump bockbuild to get mono/bockbuild#159
  * mono/mono@d6f0c25d34d: [2020-02] Bump msbuild to track mono-2019-12 (#19661)

Whenever Xamarin.Android runtime needs to instantiate a managed type,
it first looks it up by calling:

	MonoType *type = mono_reflection_type_from_name ("MyType, Assembly", nullptr);

The `nullptr` pointer refers to an instance of the Mono `MonoImage`
structure and if `nullptr`, it should cause Mono to find the correct
image containing the type and load it, if not already loaded.

The pointer is propagated down the call chain inside Mono and due to
one of the functions called not properly validating its arguments, the
`nullptr` pointer was dereferenced, leading to a crash similar to:

	libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
	crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
	/system/bin/tombstoned: received crash request for pid 11029
	crash_dump64: performing dump of process 11029 (target tid = 11029)
	DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
	DEBUG   : Revision: '0'
	DEBUG   : ABI: 'x86_64'
	DEBUG   : Timestamp: 2020-05-25 14:45:29+0200
	DEBUG   : pid: 11029, tid: 11029, name: ompanyname.app3  >>> com.companyname.app3 <<<
	DEBUG   : uid: 10134
	DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
	DEBUG   : Cause: null pointer dereference
	DEBUG   :     rax 000000000000002f  rbx 0000000000000001  rcx 0000000000000000  rdx 0000000000000030
	DEBUG   :     r8  0000000000000003  r9  000000000013e2e2  r10 0173eed800000000  r11 0000000000000206
	DEBUG   :     r12 0000000000000000  r13 00007478530343c0  r14 00007478075eda33  r15 000074780763efb0
	DEBUG   :     rdi 0000000000000000  rsi 00007478e2cb14d0
	DEBUG   :     rbp 00007ffef3a35680  rsp 00007ffef3a355d0  rip 0000747807a4066a
	DEBUG   :
	DEBUG   : backtrace:
	DEBUG   :       #00 pc 00000000003ba66a  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
	DEBUG   :       #1 pc 00000000003ba3d1  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
	DEBUG   :       #2 pc 00000000003ba26d  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
	DEBUG   :       #3 pc 000000000000ddb5  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
	DEBUG   :       #4 pc 000000000000def3  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
	DEBUG   :       #5 pc 0000000000069532  <anonymous:5ad25000>

Mono commit mono/mono@10795da1c06 fixes this issue.
jonpryor pushed a commit that referenced this issue May 28, 2020
Fixes: #4713

Context: mono/mono@10795da1c065c
Context: mono/mono@8c085a99b32e9

Changes: mono/mono@075c3f0...8c085a9

  * mono/mono@8c085a99b32: [reflection] Check whether a pointer is valid before dereferencing (#19842)
  * mono/mono@89d772a3abb: Always include Unicode charinfo, so tar made in csc mode works in mcs mode (#19813)
  * mono/mono@e9d3af508e4: Bump bockbuild to get mono/bockbuild#159
  * mono/mono@d6f0c25d34d: [2020-02] Bump msbuild to track mono-2019-12 (#19661)

Whenever Xamarin.Android runtime needs to instantiate a managed type,
it first looks it up by calling:

	MonoType *type = mono_reflection_type_from_name ("MyType, Assembly", nullptr);

The `nullptr` pointer refers to an instance of the Mono `MonoImage`
structure and if `nullptr`, it should cause Mono to find the correct
image containing the type and load it, if not already loaded.

The pointer is propagated down the call chain inside Mono and due to
one of the functions called not properly validating its arguments, the
`nullptr` pointer was dereferenced, leading to a crash similar to:

	libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
	crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
	/system/bin/tombstoned: received crash request for pid 11029
	crash_dump64: performing dump of process 11029 (target tid = 11029)
	DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
	DEBUG   : Revision: '0'
	DEBUG   : ABI: 'x86_64'
	DEBUG   : Timestamp: 2020-05-25 14:45:29+0200
	DEBUG   : pid: 11029, tid: 11029, name: ompanyname.app3  >>> com.companyname.app3 <<<
	DEBUG   : uid: 10134
	DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
	DEBUG   : Cause: null pointer dereference
	DEBUG   :     rax 000000000000002f  rbx 0000000000000001  rcx 0000000000000000  rdx 0000000000000030
	DEBUG   :     r8  0000000000000003  r9  000000000013e2e2  r10 0173eed800000000  r11 0000000000000206
	DEBUG   :     r12 0000000000000000  r13 00007478530343c0  r14 00007478075eda33  r15 000074780763efb0
	DEBUG   :     rdi 0000000000000000  rsi 00007478e2cb14d0
	DEBUG   :     rbp 00007ffef3a35680  rsp 00007ffef3a355d0  rip 0000747807a4066a
	DEBUG   :
	DEBUG   : backtrace:
	DEBUG   :       #00 pc 00000000003ba66a  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
	DEBUG   :       #1 pc 00000000003ba3d1  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
	DEBUG   :       #2 pc 00000000003ba26d  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
	DEBUG   :       #3 pc 000000000000ddb5  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
	DEBUG   :       #4 pc 000000000000def3  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
	DEBUG   :       #5 pc 0000000000069532  <anonymous:5ad25000>

Mono commit mono/mono@10795da1c06 fixes this issue.
@giuseppenovielli
Copy link

Update Xamarin.AndroidX.Lifecycle to 2.2.0.1 but STILL CRASH with AndroidEnablePreloadAssemblies = False.

There are some update??

App1.zip

@brendanzagaeski
Copy link
Contributor

@giuseppenovielli, thanks for the question. A fix for the issue has been merged to the development branch but is not yet published within Visual Studio 2019.

If everything goes as planned, this fix will be included in the next versions of Visual Studio 2019 version 16.7 Preview and Visual Studio 2019 for Mac version 8.7 Preview. I will be adding an "In Preview: " milestone to this issue along with a comment as soon as the fix is published in a Preview version.

Here's an example of how the comment will look: #4409 (comment).

@brendanzagaeski
Copy link
Contributor

Thanks again for submitting this issue!

Release status update

A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this again when a Release version is available that includes the fix.

Fix included in Xamarin.Android 10.4.0.0.

Fix included on Windows in Visual Studio 2019 version 16.7 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix included on macOS in Visual Studio 2019 for Mac version 8.7 Preview 3. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

@brendanzagaeski
Copy link
Contributor

Release status update

A new Release version of Xamarin.Android has now been published that includes the fix for this item.

Fix included in Xamarin.Android SDK version 11.0.0.3.

Fix included on Windows in Visual Studio 2019 version 16.7. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/.

Fix included on macOS in Visual Studio 2019 for Mac version 8.7. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

@ikeremozcan
Copy link

Hi @brendanzagaeski crash still happens after update of VS Mac on debug mode. Release mode working fine.
Also getting this error

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x5f656b6f766e59

My VS Mac details down below.

=== Visual Studio Community 2019 for Mac ===

Version 8.7 (build 2037)
Installation UUID: 13ce7c86-f995-46e0-9747-e20145c92d08
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000089

=== Mono Framework MDK ===

Runtime:
Mono 6.12.0.89 (2020-02/e59c1cd70f4) (64-bit)
Package version: 612000089

=== Roslyn (Language Service) ===

3.7.0-6.20371.12+917b9dfae12e3b6cb266a3c062fb20a1e9d5fb06

=== NuGet ===

Version: 5.7.0.6702

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.302/Sdks
SDK Versions:
3.1.302
3.1.301
3.1.300
3.1.202
3.1.200
3.1.102
3.1.101
3.1.100
3.0.101
3.0.100
2.1.701
2.1.700
2.1.505
2.1.504
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.6
3.1.5
3.1.4
3.1.2
3.1.1
3.1.0
3.0.1
3.0.0
2.1.20
2.1.19
2.1.18
2.1.17
2.1.16
2.1.15
2.1.14
2.1.13
2.1.12
2.1.11
2.1.9
2.1.8

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.6 (16141)
Build 11E708

=== Xamarin.Mac ===

Version: 6.20.2.2 (Visual Studio Community)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:44:59-0400

=== Xamarin.iOS ===

Version: 13.20.2.2 (Visual Studio Community)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:45:00-0400

=== Xamarin Designer ===

Version: 16.7.0.492
Hash: f5afe667d
Branch: remotes/origin/d16-7-vsmac
Build date: 2020-07-10 18:42:54 UTC

=== Xamarin.Android ===

Version: 11.0.0.3 (Visual Studio Community)
Commit: xamarin-android/d16-7/aca845b
Android SDK: /Users/keremozcan/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 28.0.3

Build Information:
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard@ebe9000
SQLite: xamarin/sqlite@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/keremozcan/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.7.0.13
Hash: 8380518
Branch: remotes/origin/dev/jmt/d16-7readconfig~2
Build date: 2020-07-23 22:38:02 UTC

=== Android Device Manager ===

Version: 16.7.0.18
Hash: 4b44bc1
Branch: remotes/origin/d16-7
Build date: 2020-07-23 22:38:26 UTC

=== Build Information ===

Release ID: 807002037
Git revision: b7706774ff5a1b761a7eb7f2d116d0d2c29ad87c
Build date: 2020-07-31 04:14:15-04
Build branch: release-8.7
Xamarin extensions: b7706774ff5a1b761a7eb7f2d116d0d2c29ad87c

=== Operating System ===

Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
Tue May 26 20:41:44 PDT 2020
root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

@grendello
Copy link
Contributor

@krmzcn it's impossible to tell if this is the same issue without stack trace, but I believe you ran across #4983 (fixed in #4993)

@ikeremozcan
Copy link

@grendello that's the problem we have facing. Thanks. It worked!

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App Runtime Issues in `libmonodroid.so`.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants