Repository navigation
Closed
Description
EDIT: in context of the final repro:
I have a net9.0-android net9.0-ios MAUI app that uses Markding for chat list bubbles labels. This works fine until cells call Parse method over 1000 times when scrolling recycled cells.
Removing those lines from Markdig fork made crashes to disappear while being able to call Parse when Markdig project is referenced in solution and compiled for Debug:
#if NET5_0_OR_GREATER
[module: System.Runtime.CompilerServices.SkipLocalsInit]
#endifThis fixed crashing when Markdig fork is refereced as project. When it's compiled for Release crashes come back again.
Those native crashes obviously can't be catched in debugger becaus they happen inside .NET optimized binaries.
Crashes:
Android:
05-24 21:08:12.399 19548 19548 D ViewRootImpl@332085e[MainActivity]: ViewPostIme pointer 1
05-24 21:08:12.419 19628 19628 E crash_dump64: unknown process state: t
05-24 21:08:12.452 19628 19628 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-24 21:08:12.453 1142 1142 I /system/bin/tombstoned: received crash request for pid 19584
05-24 21:08:12.454 19628 19628 I crash_dump64: performing dump of process 19548 (target tid = 19584)
05-24 21:08:12.463 19628 19628 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-24 21:08:12.463 19628 19628 F DEBUG : Build fingerprint: 'samsung/beyond2qltesq/beyond2q:10/QP1A.190711.020/G975USQS4DTG1:user/release-keys'
05-24 21:08:12.463 19628 19628 F DEBUG : Revision: '17'
05-24 21:08:12.463 19628 19628 F DEBUG : ABI: 'arm64'
05-24 21:08:12.463 19628 19628 F DEBUG : Timestamp: 2025-05-24 21:08:12+0300
05-24 21:08:12.463 19628 19628 F DEBUG : pid: 19548, tid: 19584, name: GLThread 6 >>> com.appomobi.app.dev <<<
05-24 21:08:12.463 19628 19628 F DEBUG : uid: 10303
05-24 21:08:12.463 19628 19628 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
05-24 21:08:12.463 19628 19628 F DEBUG : Cause: null pointer dereference
05-24 21:08:12.463 19628 19628 F DEBUG : x0 0000000000000207 x1 00000000000000d8 x2 0000000b0000001b x3 000000010000001d
05-24 21:08:12.463 19628 19628 F DEBUG : x4 00000073a7d89bf0 x5 0000000000000004 x6 00000074c1a7b000 x7 00000000003adc3a
05-24 21:08:12.463 19628 19628 F DEBUG : x8 0000000000000000 x9 0000000000000000 x10 0000000000000000 x11 0000007428f437c2
05-24 21:08:12.463 19628 19628 F DEBUG : x12 0000007428f40a1e x13 0000000000000048 x14 0000000000000000 x15 0000000000000000
05-24 21:08:12.463 19628 19628 F DEBUG : x16 00000074291ccd28 x17 00000074bbeca440 x18 00000073baa68000 x19 00000073bae4fa30
05-24 21:08:12.464 19628 19628 F DEBUG : x20 0000007428f41784 x21 00000000000000d8 x22 0000000000000001 x23 0000000000000000
05-24 21:08:12.464 19628 19628 F DEBUG : x24 0000000000000000 x25 0000000000000028 x26 000000000000001d x27 00000073c3bfbf28
05-24 21:08:12.464 19628 19628 F DEBUG : x28 0000000000000028 x29 00000073bae4f970
05-24 21:08:12.464 19628 19628 F DEBUG : sp 00000073bae4f940 lr 00000074290a5454 pc 00000074290a41f8
05-24 21:08:12.464 19628 19628 F DEBUG :
05-24 21:08:12.464 19628 19628 F DEBUG : backtrace:
05-24 21:08:12.464 19628 19628 F DEBUG : #00 pc 00000000001ca1f8 /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.464 19628 19628 F DEBUG : #01 pc 00000000001b4ae4 /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.464 19628 19628 F DEBUG : #02 pc 00000000001b44fc /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.464 19628 19628 F DEBUG : #03 pc 00000000001cddbc /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.464 19628 19628 F DEBUG : #04 pc 00000000001cdbf0 /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.464 19628 19628 F DEBUG : #05 pc 00000000001a5cdc /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.464 19628 19628 F DEBUG : #06 pc 000000000019aafc /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.465 19628 19628 F DEBUG : #07 pc 0000000000258674 /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (mono_runtime_invoke_checked+140) (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.465 19628 19628 F DEBUG : #08 pc 000000000026f2a0 /data/app/com.appomobi.app.dev-1cCxhzd6k8gLUYOw8Ea3Hg==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-24 21:08:12.465 19628 19628 F DEBUG : #09 pc 00000000000e6f10 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: b0750023d0cf44584c064da02400c159)
05-24 21:08:12.465 19628 19628 F DEBUG : #10 pc 00000000000850c8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: b0750023d0cf44584c064da02400c159)
iOS :
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000008
Exception Codes: 0x0000000000000001, 0x0000000000000008
VM Region Info: 0x8 is not in any region. Bytes before following region: 68719476728
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
commpage (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated)
Triggered by Thread: 0
Thread 0 name: tid_103 Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 AppoMobi.Mobile 0x10033a228 interp_optimize_code + 8368
1 AppoMobi.Mobile 0x10032090c generate + 1148
2 AppoMobi.Mobile 0x1003202e8 mono_interp_transform_method + 948
3 AppoMobi.Mobile 0x10033e008 tier_up_method + 616
4 AppoMobi.Mobile 0x10033dd7c mono_interp_tier_up_frame_enter + 44
5 AppoMobi.Mobile 0x100310b38 mono_interp_exec_method + 45804
6 AppoMobi.Mobile 0x100303618 interp_entry_from_trampoline + 656
7 AppoMobi.Mobile 0x1000b9970 native_to_interp_trampoline + 112
8 AppoMobi.Mobile 0x100381638 -[SKMetalViewRetained drawInMTKView:] + 104
9 MetalKit 0x1fb36e2c8 -[MTKView draw] + 155
10 QuartzCore 0x19bc0c034 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 407
11 QuartzCore 0x19bc1c9f0 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 455
12 QuartzCore 0x19bc49dc0 CA::Transaction::commit() + 643
13 QuartzCore 0x19bc17950 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 1523
14 QuartzCore 0x19bc26e38 display_timer_callback(__CFMachPort*, void*, long, void*) + 367
15 CoreFoundation 0x19a7c8de4 __CFMachPortPerform + 171
16 CoreFoundation 0x19a7e3fa0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 55
17 CoreFoundation 0x19a7e5bb4 __CFRunLoopDoSource1 + 511
18 CoreFoundation 0x19a7c9744 __CFRunLoopRun + 2331
19 CoreFoundation 0x19a7cdd20 CFRunLoopRunSpecific + 583
20 GraphicsServices 0x1d289d998 GSEventRunModal + 159
21 UIKitCore 0x19ca6034c -[UIApplication _run] + 867
22 UIKitCore 0x19ca5ffc4 UIApplicationMain + 311
23 AppoMobi.Mobile 0x1000d05a4 xamarin_UIApplicationMain + 60
24 AppoMobi.Mobile 0x100314714 do_icall + 316
25 AppoMobi.Mobile 0x100312ce8 do_icall_wrapper + 348
26 AppoMobi.Mobile 0x100306260 mono_interp_exec_method + 2580
27 AppoMobi.Mobile 0x100303e1c interp_runtime_invoke + 236
28 AppoMobi.Mobile 0x1002d26f4 mono_jit_runtime_invoke + 1244
29 AppoMobi.Mobile 0x10027a500 mono_runtime_invoke_checked + 148
30 AppoMobi.Mobile 0x100280404 mono_runtime_exec_main_checked + 116
31 AppoMobi.Mobile 0x1002d9110 mono_jit_exec + 356
32 AppoMobi.Mobile 0x100101bf4 xamarin_main + 2028
33 AppoMobi.Mobile 0x100345450 main + 64
34 dyld 0x1b7f8c344 start + 1859
Thank you for this awesome lib, using it for https://github.com/taublast/DrawnUi
Reacted by Linn Kristin Bjørkli
Metadata
Metadata
Assignees
Labels
No labels
Activity
taublast commentedon May 25, 2025
Will pull out a repro during the week, and still looking for a solution.
taublast commentedon May 26, 2025
The repro:
Create a usual .NET MAUI app, NET 9
csproj must contain:
Android latest log:
05-26 22:18:59.743 22042 22042 I DOTNET : [TEST] Markdown test 999
05-26 22:18:59.746 22042 22042 I DOTNET : [TEST] Markdown test 1000
05-26 22:18:59.747 22042 22042 W nyname.mauiapp: 0xebadde09 skipped times: 0
05-26 22:18:59.748 22042 22042 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 22042 (nyname.mauiapp1), pid 22042 (nyname.mauiapp1)
05-26 22:18:59.768 22081 22081 E crash_dump64: unknown process state: t
05-26 22:18:59.782 22081 22081 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-26 22:18:59.782 1142 1142 I /system/bin/tombstoned: received crash request for pid 22042
05-26 22:18:59.783 22081 22081 I crash_dump64: performing dump of process 22042 (target tid = 22042)
05-26 22:18:59.788 22081 22081 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-26 22:18:59.789 22081 22081 F DEBUG : Build fingerprint: 'samsung/beyond2qltesq/beyond2q:10/QP1A.190711.020/G975USQS4DTG1:user/release-keys'
05-26 22:18:59.789 22081 22081 F DEBUG : Revision: '17'
05-26 22:18:59.789 22081 22081 F DEBUG : ABI: 'arm64'
05-26 22:18:59.789 22081 22081 F DEBUG : Timestamp: 2025-05-26 22:18:59+0300
05-26 22:18:59.789 22081 22081 F DEBUG : pid: 22042, tid: 22042, name: nyname.mauiapp1 >>> com.companyname.mauiapp1 <<<
05-26 22:18:59.789 22081 22081 F DEBUG : uid: 10306
05-26 22:18:59.789 22081 22081 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
05-26 22:18:59.789 22081 22081 F DEBUG : Cause: null pointer dereference
05-26 22:18:59.789 22081 22081 F DEBUG : x0 00000000000002f2 x1 0000000000000132 x2 0000000b00000024 x3 0000000100000026
05-26 22:18:59.789 22081 22081 F DEBUG : x4 00000073c2cc8960 x5 0000000000000004 x6 00000074c1a7b000 x7 00000000009c39dc
05-26 22:18:59.789 22081 22081 F DEBUG : x8 0000000000000000 x9 0000000000000000 x10 0000000000000000 x11 0000007428f2d7c2
05-26 22:18:59.789 22081 22081 F DEBUG : x12 0000007428f2aa1e x13 0000000000000048 x14 0000000000000000 x15 0000000000000000
05-26 22:18:59.789 22081 22081 F DEBUG : x16 00000074291b6d28 x17 00000074bbeca440 x18 00000074c15f8000 x19 0000007fd98cfa90
05-26 22:18:59.789 22081 22081 F DEBUG : x20 0000007428f2b784 x21 0000000000000132 x22 0000000000000001 x23 0000000000000000
05-26 22:18:59.789 22081 22081 F DEBUG : x24 0000000000000000 x25 0000000000000028 x26 0000000000000026 x27 00000073c2c97c28
05-26 22:18:59.789 22081 22081 F DEBUG : x28 0000000000000028 x29 0000007fd98cf9d0
05-26 22:18:59.789 22081 22081 F DEBUG : sp 0000007fd98cf9a0 lr 000000742908f454 pc 000000742908e1f8
05-26 22:18:59.858 22081 22081 F DEBUG :
05-26 22:18:59.858 22081 22081 F DEBUG : backtrace:
05-26 22:18:59.858 22081 22081 F DEBUG : #00 pc 00000000001ca1f8 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.858 22081 22081 F DEBUG : #1 pc 00000000001b4ae4 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.858 22081 22081 F DEBUG : #2 pc 00000000001b44fc /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.858 22081 22081 F DEBUG : #3 pc 00000000001cddbc /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.858 22081 22081 F DEBUG : #4 pc 00000000001cdbf0 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.858 22081 22081 F DEBUG : #5 pc 00000000001a5cdc /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.858 22081 22081 F DEBUG : #6 pc 000000000019aafc /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.858 22081 22081 F DEBUG : #7 pc 0000000000258674 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (mono_runtime_invoke_checked+140) (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #8 pc 000000000026087c /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #9 pc 000000000021b888 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #10 pc 000000000022463c /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #11 pc 00000000001a92d0 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #12 pc 00000000001a7b20 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #13 pc 000000000019ce78 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #14 pc 00000000001a9684 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #15 pc 00000000001a9e00 /data/app/com.companyname.mauiapp1-Gf-7hkc2ua1dDp6rZ_zCYA==/lib/arm64/libmonosgen-2.0.so (BuildId: 1be7c7c5272957bf2e9a5560cbbed0b969688e5a)
05-26 22:18:59.859 22081 22081 F DEBUG : #16 pc 000000000000e614 anonymous:7424376000
[-]Crashing on iOS and Android under heavy concurrent usage[/-][+]Crashing on iOS and Android after usage over 1000 times[/+]taublast commentedon May 27, 2025
Maybe they hardcoded "1000" in somewhere https://github.com/dotnet/runtime but remains to know if a quick workaround for a Markdig custom fork is possible until the cause is found and fixe.. Any help would be much appreciated!
taublast commentedon May 27, 2025
Okay i see that we have a lot of hardcoded "1000" inside Markdig itsself :)
xoofx commentedon May 27, 2025
None of them can be related to the bug you are experiencing.
The issue you are facing seems to be a Mono codegen/GC issue on ARM64.
taublast commentedon May 27, 2025
Indeed. Any idea what i could change inside Markdig, no matter performance, to just jump over it like today?
xoofx commentedon May 27, 2025
This code:
is triggering a fraction of the coverage in Markdig (Just tested it, and it is less than 10% on desktop). The code that is covered is so minimal that I'm skeptical that the issue is in Markdig but a combined effect. It could be anything, like MAUI trashing managed memory, and while Markdig is running, the GC is going over a pointer that it should not visit (the
0x8invalid address in the crashes).You could try to reference the Markdig netstandard 2.0 manually instead of net8.0+ resolved via NuGet to check if it happens with different code path. I would also remove the
Console.WriteLineto see how much it affects the timing. I would replace the usage of Markdig with e.g. Scriban to perform a similar workload with managed objects. Difference between Markdig and Scriban is that Markdig has a few places where it plays with managed references with unsafe code that could trigger an invalid codegen/GC case in Mono ARM64. I would also try to move the loop to another place (e.g. not in a constructor) to see if it happens as well (e.g. plug it behind a button click)taublast commentedon May 27, 2025
Thanks! Console is here only for repro, this all happens no matter if we use it. Any personal theories about "Why 1000"? Obviously i would need to create a repro without Markdig then..
Edit: for netstandard 2.1 result is the same.
BrzVlad commentedon May 28, 2025
Thank you very much for the repro. I confirm this is issue in
dotnet/runtime.MihaZupan commentedon May 28, 2025
Thank you for helping track this one down.