Open Adam-- opened 11 months ago
This issue makes development on .NET 7/MAUI extremely difficult. Any help toward a fix would be greatly appreciated!
@Adam-- I've just tried to repro the issue on newer Android APIs and the test app works as expected, however I have a handful of questions if you could please answer them:
I need to hunt for an older device with API 25 (ARM emulators for some reason don't work for me, they fail to start) but, in the meantime, could you record a logcat of your crash using the following steps.
> adb shell setprop debug.mono.log default,assembly,timing=bare,mono_log_level=debug,mono_log_mask=all
> adb logcat -G 16M
> adb logcat -c
rem start the application on device here
rem after it crashes, wait for 1-2 seconds and then
> adb logcat -d > logcat.txt
Please attach the resulting logcat.txt
file.
Hi @Adam--. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@grendello
Are your tests on arm64 or arm32?
Arm32.
I gathered a handful of devices, and this is what I've found:
Moto G 5 Plus - Android 8.1 API 27 (armeabi-v7a) - Has issue LGE Nexus 5X - Android 8.1 API 27 (arm64-v8a) - Does not have issue Moto x4 - Android 9.0 API 28 (arm64-v8a) - Does not have issue
It's a small sample set, but it certainly looks like it's an issue on arm32 devices/emulators.
Does the app crash in Debug build, Release, both? If the crash happens in Debug, does it happen while the debugger is attached?
It happens in debug with or without the debugger attached. It doesn't happen in release.
Would you be able to test with net8 preview if the crash happens there as well?
The same issue happens in .NET 8 preview.
I need to hunt for an older device with API 25 (ARM emulators for some reason don't work for me, they fail to start)
I have the same problem with ARM 64 bit emulators, 32 bit works fine for me though.
…record a logcat of your crash using the following steps.
Attached:
@Adam-- thanks for the answers and the logcat! Alas, the native stack trace reveals precious little about the case, except for the fact that it happens in the Mono runtime so it might be where the bug lurks.
I managed to install your sample (but built for net8) in an arm32 emulator (API 27 with Google APIs), where the app does crash, but it's not a segfault anymore:
09-06 20:11:41.736 7253 7253 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 7253 (e.mauirudecrash)
09-06 20:11:41.741 693 693 W : debuggerd: handling request: pid=7253 uid=10084 gid=10084 tid=7253
09-06 20:11:41.814 7277 7277 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-06 20:11:41.815 7277 7277 F DEBUG : Build fingerprint: 'Android/sdk_google_phone_armv7/generic:7.1.1/NYC/6695155:userdebug/test-keys'
09-06 20:11:41.815 7277 7277 F DEBUG : Revision: '0'
09-06 20:11:41.815 7277 7277 F DEBUG : ABI: 'arm'
09-06 20:11:41.816 7277 7277 F DEBUG : pid: 7253, tid: 7253, name: e.mauirudecrash >>> com.companyname.mauirudecrash <<<
09-06 20:11:41.816 7277 7277 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
09-06 20:11:41.829 7277 7277 F DEBUG : r0 00000000 r1 00001c55 r2 00000006 r3 00000008
09-06 20:11:41.829 7277 7277 F DEBUG : r4 ae033584 r5 00000006 r6 ae03352c r7 0000010c
09-06 20:11:41.829 7277 7277 F DEBUG : r8 00000004 r9 00000000 sl 00000000 fp 8e1d01c0
09-06 20:11:41.829 7277 7277 F DEBUG : ip 0000000b sp bec14618 lr acb1e41f pc acb20c6c cpsr 20000010
09-06 20:11:41.858 7277 7277 F DEBUG :
09-06 20:11:41.858 7277 7277 F DEBUG : backtrace:
09-06 20:11:41.859 7277 7277 F DEBUG : #00 pc 00048c6c /system/lib/libc.so (tgkill+12)
09-06 20:11:41.860 7277 7277 F DEBUG : #01 pc 0004641b /system/lib/libc.so (pthread_kill+34)
09-06 20:11:41.860 7277 7277 F DEBUG : #02 pc 0001c6fd /system/lib/libc.so (raise+10)
09-06 20:11:41.860 7277 7277 F DEBUG : #03 pc 0001825f /system/lib/libc.so (__libc_android_abort+34)
09-06 20:11:41.860 7277 7277 F DEBUG : #04 pc 00017798 /system/lib/libc.so (abort+4)
09-06 20:11:41.860 7277 7277 F DEBUG : #05 pc 0001ade1 /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonodroid.so (_ZN7xamarin7android7Helpers17abort_applicationEv+4)
09-06 20:11:41.861 7277 7277 F DEBUG : #06 pc 000321c3 /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonodroid.so (_ZN7xamarin7android8internal16MonodroidRuntime16mono_log_handlerEPKcS4_S4_iPv+66)
09-06 20:11:41.861 7277 7277 F DEBUG : #07 pc 001591cd /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonosgen-2.0.so
09-06 20:11:41.861 7277 7277 F DEBUG : #08 pc 0014faf5 /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonosgen-2.0.so
09-06 20:11:41.861 7277 7277 F DEBUG : #09 pc 0014fb95 /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonosgen-2.0.so
09-06 20:11:41.861 7277 7277 F DEBUG : #10 pc 0014fbc7 /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonosgen-2.0.so
09-06 20:11:41.861 7277 7277 F DEBUG : #11 pc 00186b79 /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonosgen-2.0.so
09-06 20:11:41.862 7277 7277 F DEBUG : #12 pc 0018d3b3 /data/app/com.companyname.mauirudecrash-1/lib/arm/libmonosgen-2.0.so
This is without debugger attached, a Debug
build. Unfortunately, the actual reason for MonoVM to log a fatal error is not logged :(, so we're not closer to discovering what actually causes the crash.
Since I don't have any old devices handy atm (at least not working ones...), would you be able to repeat the adb
steps mentioned earlier for all the devices and emulators you can reproduce this on and attach their respective logcat dumps?
Also, could you check whether your net8 build crashed with SIGABRT
as in my excerpt above, or was it a SIGSEGV
as with net7?
Finally, would you be able to check if an arm32 build of your app crashes on an arm64 device? Thanks!
@grendello here you go, hope these logs help.
NET7 ARM32 Crashes boundary-7.1-ARM32-logcat.txt:
--------- beginning of crash
05-02 14:43:17.591 4831 4831 F libc : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x91a41430 in tid 4831 (e.mauirudecrash)
05-02 14:43:17.591 209 209 W : debuggerd: handling request: pid=4831 uid=10032 gid=10032 tid=4831
05-02 14:43:17.677 4912 4912 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-02 14:43:17.677 4912 4912 F DEBUG : Build fingerprint: 'boundary/lakeshore/lakeshore:7.1.1/ls3.0.0_SNAPSHOT-20230419/20230419:userdebug/release-keys'
05-02 14:43:17.677 4912 4912 F DEBUG : Revision: '0'
05-02 14:43:17.677 4912 4912 F DEBUG : ABI: 'arm'
05-02 14:43:17.678 4912 4912 F DEBUG : pid: 4831, tid: 4831, name: e.mauirudecrash >>> com.companyname.mauirudecrash <<<
05-02 14:43:17.678 4912 4912 F DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x91a41430
05-02 14:43:17.678 4912 4912 F DEBUG : r0 92850ba0 r1 00000000 r2 00000000 r3 00000000
05-02 14:43:17.678 4912 4912 F DEBUG : r4 bef708e8 r5 ab44f4e4 r6 9f373300 r7 91a41430
05-02 14:43:17.678 4912 4912 F DEBUG : r8 bef708e8 r9 9f37330e sl 00000000 fp acabe648
05-02 14:43:17.678 4912 4912 F DEBUG : ip 00000000 sp bef70750 lr 00000000 pc 91a41430 cpsr 600f0010
05-02 14:43:17.681 4912 4912 F DEBUG :
05-02 14:43:17.681 4912 4912 F DEBUG : backtrace:
05-02 14:43:17.681 4912 4912 F DEBUG : #00 pc 00000430 <anonymous:91a41000>
05-02 14:43:17.681 4912 4912 F DEBUG : #01 pc 00000000 <unknown>
--- beginning of crash
09-07 12:28:37.039 20431 20431 F libc : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x941c0430 in tid 20431 (e.mauirudecrash), pid 20431 (e.mauirudecrash)
09-07 12:28:37.093 20489 20489 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
09-07 12:28:37.093 1119 1119 I /system/bin/tombstoned: received crash request for pid 20431
09-07 12:28:37.094 20489 20489 I crash_dump32: performing dump of process 20431 (target tid = 20431)
09-07 12:28:37.094 20489 20489 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-07 12:28:37.094 20489 20489 F DEBUG : Build fingerprint: 'motorola/potter/potter:8.1.0/OPSS28.85-17-6/21457:user/release-keys'
09-07 12:28:37.094 20489 20489 F DEBUG : Revision: 'p3b0'
09-07 12:28:37.095 20489 20489 F DEBUG : ABI: 'arm'
09-07 12:28:37.095 20489 20489 F DEBUG : pid: 20431, tid: 20431, name: e.mauirudecrash >>> com.companyname.mauirudecrash <<<
09-07 12:28:37.095 20489 20489 F DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x941c0430
09-07 12:28:37.095 20489 20489 F DEBUG : r0 95079af0 r1 00000000 r2 00000030 r3 befe2ef0
09-07 12:28:37.095 20489 20489 F DEBUG : r4 befe30a8 r5 af44d3e4 r6 954e9300 r7 941c0430
09-07 12:28:37.095 20489 20489 F DEBUG : r8 befe30a8 r9 954e930e sl 00000000 fp 94009648
09-07 12:28:37.095 20489 20489 F DEBUG : ip 00000000 sp befe2f10 lr 95a3de07 pc 941c0430 cpsr 600f0010
09-07 12:28:37.096 20489 20489 F DEBUG :
09-07 12:28:37.096 20489 20489 F DEBUG : backtrace:
09-07 12:28:37.096 20489 20489 F DEBUG : #00 pc 00000430 <anonymous:941c0000>
09-07 12:28:37.096 20489 20489 F DEBUG : #01 pc 001fce03 /data/app/com.companyname.mauirudecrash-NrFGKHEAN_p79oG3j4kJog==/lib/arm/libmonosgen-2.0.so
09-07 12:28:37.096 20489 20489 F DEBUG : #02 pc 00027ddc <anonymous:95000000>
emulator-pixel5-7.1-ARM32-logcat.txt:
09-07 12:45:08.548 12732 12732 F libc : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x97890318 in tid 12732 (e.mauirudecrash)
09-07 12:45:08.553 693 693 W : debuggerd: handling request: pid=12732 uid=10084 gid=10084 tid=12732
09-07 12:45:08.557 693 693 E : debuggerd: waitpid returned unexpected pid (0), committing murder-suicide
09-07 12:45:08.557 693 693 W : debuggerd: pid 0 received signal 9
09-07 12:45:08.558 693 693 E : debuggerd: killing target 12732
09-07 12:45:08.688 5264 7237 W WindowManager: Failed looking up window
09-07 12:45:08.688 5264 7237 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@ef56534 does not exist
09-07 12:45:08.688 5264 7237 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9422)
09-07 12:45:08.688 5264 7237 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9413)
09-07 12:45:08.688 5264 7237 W WindowManager: at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2393)
09-07 12:45:08.688 5264 7237 W WindowManager: at com.android.server.wm.Session.remove(Session.java:202)
09-07 12:45:08.688 5264 7237 W WindowManager: at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:242)
09-07 12:45:08.688 5264 7237 W WindowManager: at com.android.server.wm.Session.onTransact(Session.java:145)
09-07 12:45:08.688 5264 7237 W WindowManager: at android.os.Binder.execTransact(Binder.java:565)
09-07 12:45:08.742 12760 12760 I : debuggerd: starting
09-07 12:45:08.823 12425 12553 I GrammarCompilationSvcCt: Grammar compilation alarm set for interval 604800000
09-07 12:45:08.982 5264 7237 I ActivityManager: Process com.companyname.mauirudecrash (pid 12732) has died
NET8 ARM32 Crash net8-boundary-7.1-ARM32-logcat.txt:
--------- beginning of crash
05-02 16:05:49.508 6307 6307 F libc : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x92900640 in tid 6307 (ame.mauiappnet8)
05-02 16:05:49.508 209 209 W : debuggerd: handling request: pid=6307 uid=10033 gid=10033 tid=6307
05-02 16:05:49.591 6400 6400 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-02 16:05:49.592 6400 6400 F DEBUG : Build fingerprint: 'boundary/lakeshore/lakeshore:7.1.1/ls3.0.0_SNAPSHOT-20230419/20230419:userdebug/release-keys'
05-02 16:05:49.592 6400 6400 F DEBUG : Revision: '0'
05-02 16:05:49.592 6400 6400 F DEBUG : ABI: 'arm'
05-02 16:05:49.592 6400 6400 F DEBUG : pid: 6307, tid: 6307, name: ame.mauiappnet8 >>> com.companyname.mauiappnet8 <<<
05-02 16:05:49.592 6400 6400 F DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x92900640
05-02 16:05:49.592 6400 6400 F DEBUG : r0 924e7fc0 r1 00000000 r2 00000000 r3 00000000
05-02 16:05:49.592 6400 6400 F DEBUG : r4 bef708c0 r5 00000000 r6 92f51691 r7 8f33bb60
05-02 16:05:49.592 6400 6400 F DEBUG : r8 ab42bd64 r9 bef708c0 sl 8f33bb6e fp 8f33e528
05-02 16:05:49.592 6400 6400 F DEBUG : ip 00000000 sp bef70698 lr 00000000 pc 92900640 cpsr 600f0010
05-02 16:05:49.594 6400 6400 F DEBUG :
05-02 16:05:49.594 6400 6400 F DEBUG : backtrace:
05-02 16:05:49.594 6400 6400 F DEBUG : #00 pc 00000640 <anonymous:92900000>
05-02 16:05:49.594 6400 6400 F DEBUG : #01 pc 00000000 <unknown>
ARM32 build on 64 bit device Crashes with
[libc] Fatal signal 11 (SIGSEGV), code 2, fault addr 0xc64a3430 in tid 14104 (e.mauirudecrash)
@Adam-- thanks for the logs! They don't reveal anything new, alas, but at least we have a fairly consistent pattern.
@lambdageek @vargaz I think this might be a JIT bug? Would you be able to take a look?
@Adam-- could you try building (from scratch) and running your app with the $(AndroidUseInterpreter)
MSBuild property set to false
?
@grendello, with AndroidUseInterpreter set to false, the "Fatal signal 11 (SIGSEGV)" issue goes away and I get the expected unhandled exception:
**System.Exception:** 'Loading...'
**System.Reflection.TargetInvocationException:** 'Exception has been thrown by the target of an invocation.'
**System.Reflection.TargetInvocationException:** 'Exception has been thrown by the target of an invocation.'
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
[mono-rt] ---> System.Exception: This is a rude crash!
[mono-rt] at MauiRudeCrash.MainPage..ctor() in C:\SourceCode\Other\MauiRudeCrash\MainPage.xaml.cs:line 11
[mono-rt] at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
[mono-rt] --- End of inner exception stack trace ---
[mono-rt] at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
[mono-rt] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
[mono-rt] at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
[mono-rt] at System.Activator.CreateInstance(Type type, Boolean nonPublic)
[mono-rt] at System.Activator.CreateInstance(Type type)
[mono-rt] at Microsoft.Maui.Controls.ShellContent.<>c__DisplayClass19_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0() in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 75
[mono-rt] at Microsoft.Maui.Controls.ElementTemplate.CreateContent() in D:\a\_work\1\s\src\Controls\src\Core\ElementTemplate.cs:line 85
[mono-rt] at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(DataTemplate self, Object item, BindableObject container) in D:\a\_work\1\s\src\Controls\src\Core\DataTemplateExtensions.cs:line 22
[mono-rt] at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent() in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 80
[mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellSectionRenderer.cs:line 123
[mono-rt] at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) in /Users/runner/work/1/s/generated/androidx.fragment.fragment/obj/Release/net6.0-android/generated/src/AndroidX.Fragment.App.Fragment.cs:line 2031
[mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 352
@Adam-- great! If you don't use hot reload, you can leave that property set to false
then. This is a Mono runtime issue then, @lambdageek, @vargaz over to you :)
Thanks @grendello for the workaround, I appreciate it! That's C# hot reload that gets disabled, XAML hot reload would be unaffected, right? Also, are there any other tradeoffs with disabling the interpreter? Slower deployment and debugging, APK size, compatibility?
@Adam-- yw. The shortest answer to your question is "it depends"... :) Interpreter may give you faster startup if there are a lot of (like thousands) methods to be JIT-ed at startup that are called only once, but it will in general give you slower performance of code that's called repeatedly. A general rule is that in most cases interpreter is slower. It shouldn't affect APK size at all, nor will it affect deployment times. I don't know if it affects XAML hot reload, my guess would be that it doesn't, @jonathanpeppers any idea?
The interpreter has slightly faster startup, but slower at things like math in for-loops. Here are some ideas of startup time from the past:
https://github.com/jonathanpeppers/maui-profiling
Turning off the interpreter will disable C# hot reload, but XAML hot reload should continue working. Note that they sometimes work together like XAML-changes in x:Name
elements, for example.
If this is a runtime problem, could this be moved to dotnet/runtime ?
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 2022 17.7.3
Description
When running on an ARM device and an unhandled exception is thrown a crash is observed with a "[libc] Fatal signal 11 (SIGSEGV)" error and no other information in the logs or IDE.
Steps to Reproduce
Create a new MAUI app In MainPage.xaml.cs constructor, throw an exception.
MauiRudeCrash.zip
Did you find any workaround?
No
Relevant log output
Run on Android 7.1 API 25 ARM device (does not work as expected):
Run on Android 7.1 API 25 ARM emulator (does not work as expected):
Run on Android 7.1 API 25 x86 emulator (works as expected):
Run on Android 13 API 33 x86 emulator (works as expected):