mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-08 21:37:02 +00:00
Crashing on iOS and Android after usage over 1000 times #741
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @taublast on GitHub (May 25, 2025).
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
Parsemethod over 1000 times when scrolling recycled cells.Removing those lines from Markdig fork made crashes to disappear while being able to call
Parsewhen Markdig project is referenced in solution and compiled for Debug:This 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:
iOS :
Thank you for this awesome lib, using it for https://github.com/taublast/DrawnUi
@taublast commented on GitHub (May 25, 2025):
Will pull out a repro during the week, and still looking for a solution.
@taublast commented on GitHub (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 : #01 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 : #02 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 : #03 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 : #04 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 : #05 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 : #06 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 : #07 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 : #08 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 : #09 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
@taublast commented on GitHub (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 commented on GitHub (May 27, 2025):
Okay i see that we have a lot of hardcoded "1000" inside Markdig itsself :)
@xoofx commented on GitHub (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 commented on GitHub (May 27, 2025):
Indeed. Any idea what i could change inside Markdig, no matter performance, to just jump over it like today?
@xoofx commented on GitHub (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 commented on GitHub (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 commented on GitHub (May 28, 2025):
Thank you very much for the repro. I confirm this is issue in
dotnet/runtime.@MihaZupan commented on GitHub (May 28, 2025):
Thank you for helping track this one down.