dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.45k stars 4.76k forks source link

mono_gc_run_finalize iOS crash #107448

Open timmac-qmc opened 2 months ago

timmac-qmc commented 2 months ago

Description

I'm getting numerous crash reports from users when opening our MAUI Blazor Hybrid app on iOS with the following stack trace:

0   libsystem_kernel.dylib          0x00000001e74eb42c __pthread_kill + 8 (:-1)
1   libsystem_pthread.dylib         0x00000001fb28ac0c pthread_kill + 268 (pthread.c:1721)
2   libsystem_c.dylib               0x00000001a638eba0 abort + 180 (abort.c:118)
3   QMCMobile                       0x00000001031f29ac 0x102a80000 + 7809452
4   QMCMobile                       0x000000010317630c mono_runtime_setup_stat_profiler + 0 (mini-posix.c:662)
5   libsystem_platform.dylib        0x00000001fb1cee9c _sigtramp + 56 (sigtramp.c:116)
6   libsystem_pthread.dylib         0x00000001fb28ac0c pthread_kill + 268 (pthread.c:1721)
7   libsystem_c.dylib               0x00000001a638eba0 abort + 180 (abort.c:118)
8   QMCMobile                       0x0000000102ea9dd4 print_callback(char const*, int) + 0 (runtime.m:1201)
9   QMCMobile                       0x000000010302bfd0 monoeg_g_logv_nofree + 212 (goutput.c:167)
10  QMCMobile                       0x000000010302c040 monoeg_assertion_message + 40 (goutput.c:207)
11  QMCMobile                       0x00000001030f4bac mono_unhandled_exception_checked + 0 (object.c:4540)
12  QMCMobile                       0x00000001031030c4 mono_thread_internal_unhandled_exception + 48 (threads.c:4673)
13  QMCMobile                       0x0000000103125ec4 mono_gc_run_finalize + 684 (gc.c:352)
14  QMCMobile                       0x0000000103050624 sgen_gc_invoke_finalizers + 192 (sgen-gc.c:2852)
15  QMCMobile                       0x00000001031270d8 finalizer_thread + 776 (gc.c:905)
16  QMCMobile                       0x000000010310395c start_wrapper + 352 (threads.c:1271)
17  libsystem_pthread.dylib         0x00000001fb28906c _pthread_start + 136 (pthread.c:931)
18  libsystem_pthread.dylib         0x00000001fb2840d8 thread_start + 8 (:-1)

The crash is sporadic, I can reproduce it in the release version but sometimes the app opens fine, others it crashes almost instantly when opening. 2024-09-0511-36-23.7199+0100-a81f98656fd14cd6ee1031f7089dfc2e6b30f05c.txt

Reproduction Steps

Open iOS release version

Expected behavior

App opens as expected

Actual behavior

App crashes instantly

Regression?

No response

Known Workarounds

No response

Configuration

iOS 17.x+ ARM64 Release version MAUI Blazor Hybrid App

Other information

No response

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @brzvlad See info in area-owners.md if you want to be subscribed.

BrzVlad commented 2 months ago

Seems like there is an exception thrown by a finalizer and then we crash in the runtime, maybe due to bad thread gc state transition. Could you provide some repro project ?

timmac-qmc commented 2 months ago

The app is a company project so I'm unable to share unfortunately, you may be able to reproduce the crash on the released app if that's of any use?

https://apps.apple.com/gb/app/QMC/id6480462390