Repository navigation
Description
Android framework version
net10.0-android
Affected platform version
.NET 10, Android runtime pack Microsoft.Android.Runtime.Mono.36.android-arm64 36.1.30 (verified by SHA-256 of libmonodroid.so in shipped AAB); crash signature observed since at least May 2026 on earlier versions too. Devices: Samsung/Pixel/others, Android 12-16, arm64-v8a.
Description
Production .NET MAUI app (net10.0-android, Mono runtime, full AOT with RunAOTCompilation=true, assembly store), ~8,000-device fleet. We collect ApplicationExitInfo records (incl. native-crash tombstones). One native crash signature dominates everything else:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 // sometimes 0x4
Crashed thread: <main thread> // or ".NET TP Worker"
#00 libart.so +0x69ecf0 art::JNI<false>::GetObjectClass(_JNIEnv*, _jobject*)
dotnet/android#1 split_config.arm64_v8a.apk +0x59f50 // earlier app build: +0x58be0
Frequency: ~330 crash events from ~290 distinct devices per week (~4% of the fleet weekly, ~40-60/day in steady state). It occurs on both the UI thread and thread-pool threads, across unrelated screens, elevated under GC pressure (e.g. heavy allocation right after app update: DB migration + full data sync) but persistent during completely normal use.
Frame #1 identified — shared AOT transition wrapper, race window visible
We symbolized frame #1 by recompiling Java.Interop.dll with mono-aot-cross keeping symbols (the Android SDK's AOT step passes -s in ld-flags, so shipped AOT images are always stripped) and byte-matching against the stripped image from our shipped AAB (code regions are byte-identical at the same file offsets between runtime 36.1.30 and 36.1.43):
- Both offsets are inside Mono's shared managed-to-native
native_indirectsignature wrappers inlibaot-Java.Interop.dll.so(wrapper_managed_to_native ... wrapper_native_indirect_...).+0x59f50is exactly the wrapper's indirect call instruction (blr x2) for the 2-argument signature matchingGetObjectClass(env, jobject)— unwinders report caller frames as LR-4. Because the wrappers are shared per signature, every caller funnels through the same address — hence exactly one offset per app build across the whole fleet. - The race window: the wrapper calls
mono_threads_enter_gc_safe_region_unbalancedimmediately before the indirect JNI call. The rawjobjectwas extracted from theJniObjectReferencebefore entering GC-safe mode; a collection (and GC-bridge handle processing) running concurrently in that window can invalidate the handle, so ART dereferences a danglingjobject→ SIGSEGV with fault addr 0x0/0x4. - IL scan of the linked assemblies shows the managed
GetObjectClasscallers funneling into this wrapper:JniRuntime.JniValueManager.CreatePeer,AndroidTypeManager/JavaTypeManager.CreateInstance(the Java→managed peer-creation path),JniEnvironment.Types.GetJniTypeNameFromInstance,Android.Runtime.JNIEnv.GetObjectClass/InvokeConstructor/AssertCompatibleArrayTypes,JavaConvert.GetTypeMapping. - Ruled out on the native side: the exact shipped
libmonodroid.so(36.1.30) contains fiveJNIEnv->GetObjectClasscall sites (init + 4 inOSBridge), none matching the crash offsets;libmonosgen-2.0.soand the crypto PAL contain none.
Possibly related: dotnet/runtime#123495 (SIGSEGV inside sgen-tarjan-bridge.c on .NET 10 Android), dotnet/runtime#112109.
Related diagnosability gap
The crashing thread's backtrace always ends at frame #1 because Mono's Android AOT emits no OS-readable unwind info — no .eh_frame/PT_GNU_EH_FRAME in the AOT images, and the LLVM AOT backend likewise generates assembly without any .cfi directives (verified with mono-aot-cross ... llvm). Consequently no Mono-based Android app can symbolize past the first managed frame in ApplicationExitInfo / Play Console / Crashlytics native crash reports. If AOT could emit CFI (even optionally), issues like this one would arrive with full stacks.
We can attach full tombstones (all threads + memory maps) and the exact shipped libmonodroid.so / libaot-*.so binaries on request, and we can measure any candidate fix at fleet scale within days via a staged rollout.
Steps to Reproduce
No deterministic repro — statistical at fleet scale (hundreds of events/week, ~4% of devices weekly). Elevated under GC pressure (first launch after app update: database migration + full sync), but occurs steadily during normal use on both UI and thread-pool threads. We are setting up a local repro rig (debuggable build + CheckJNI + small nursery GC stress + UI soak) and can run experimental builds.
Did you find any workaround?
Not yet. Evaluating MONO_GC_PARAMS=bridge-implementation=old and the latest servicing runtime (36.1.69) as mitigations; happy to report fleet-scale telemetry for either.
Relevant log output
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
jonathanpeppers commentedon Aug 11, 2026
Can you share the full logcat output, this is just a snippet:
branomalovec commentedon Aug 11, 2026
Thanks for the quick look @jonathanpeppers.
There is unfortunately no logcat to share: these reports come from production devices via
ApplicationExitInfo.getTraceInputStream()telemetry (REASON_CRASH_NATIVE → tombstone proto), not from a device we hold. The two-frame backtrace is the complete backtrace of the crashing thread as the platform produced it — nothing on our side trims it (our uploader prints up to 10 frames, and other native crashes from the same fleet do show deeper stacks, e.g. libc/e_sqlite3 ones). The unwind ends at frame #1 because the AOT images carry no unwind info (no.eh_frame/PT_GNU_EH_FRAME, and no.cfidirectives even from the LLVM AOT backend), as described in the "diagnosability gap" section — the OS unwinder recovers frame #1 from LR and cannot walk past AOT code.What I can offer instead, immediately:
1. Disassembly of the faulting wrapper from the shipped
libaot-Java.Interop.dll.so(symbolized via a byte-identicalmono-aot-crossrebuild of the same runtime version). Frame#01 = +0x59f50is theblr x2below. Note the shape: the call target and argument values are captured in the wrapper frame at entry, then the thread enters the GC-safe region, and only then the JNI function is invoked:The
jobjectargument value is fixed beforemono_threads_enter_gc_safe_region_unbalanced; once the thread is GC-safe, a concurrent collection + GC-bridge handle processing can invalidate that handle before/while ART dereferences it (fault addr 0x0/0x4insideart::JNI<false>::GetObjectClass).2. Binaries on request: the exact shipped
libmonodroid.so(runtime pack 36.1.30), the strippedlibaot-Java.Interop.dll.sofrom our AAB, and the symbol-bearing rebuild used for the analysis — tell me the preferred way to hand them over and I'll attach a zip.3. Full tombstone (all threads + memory maps): stored in per-device diagnostics; we've asked support to obtain an upload from an affected device and I'll attach the first one that arrives. We're also building a local repro rig (debuggable build + CheckJNI + small-nursery GC stress + UI soak) — if it fires, I'll attach the complete logcat from that.
We can also run any experimental build and report fleet-scale telemetry within days (staged rollout, ~330 events/week baseline).
jonathanpeppers commentedon Aug 11, 2026
@branomalovec so all of these are calls inside
libmonosgen-2.0.so? If so, I can move this to the dotnet/runtime repo.branomalovec commentedon Aug 11, 2026
Not quite — the faulting call site is not in
libmonosgen-2.0.so. To be precise about where each piece lives:libaot-Java.Interop.dll.so— the Mono AOT image compiled fromJava.Interop.dll. Specifically it's the AOT-generated shared managed-to-nativenative_indirectwrapper (disassembly in my previous comment), i.e. code emitted by the Mono AOT compiler, not hand-written runtime code.libart.so(art::JNI<false>::GetObjectClassdereferencing the danglingjobject).libmonosgen-2.0.soitself contains noGetObjectClasscall sites (we checked), but we do also see a smaller sibling family of native crashes with frames directly insidelibmonosgen-2.0.so(~15 events/week, same fleet) — consistent with runtime/GC involvement.So the machinery involved in the race is split:
mono_threads_enter/exit_gc_safe_region_unbalanced, and SGen + GC-bridge handle processing are dotnet/runtime (src/mono) territory;IntPtrfromJniObjectReferenceand invokes through the function-pointer table is Java.Interop (this org).The fix could plausibly land on either side (revalidate/pin the handle across the GC-safe transition in Java.Interop, or don't invalidate in-flight handles in the runtime's bridge processing). Given the crash mechanics are GC/wrapper-level, moving to dotnet/runtime sounds right to me — possibly related to dotnet/runtime#123495 which is already in that repo. Happy to follow the issue wherever it goes and provide binaries/telemetry there.
jonathanpeppers commentedon Aug 11, 2026
This would be dotnet/runtime.
👍
espenrl commentedon Aug 26, 2026
We have a massive amount of these reported compared to the number of device installs. And with no possibility to discover the reason why. The best details we get are the following through Google Console.
lateralusX commentedon Sep 10, 2026
The Mono-generated
wrapper_native_indirectcode appears to be behaving as intended. It enters a GC-safe region around the unmanaged JNI call and receives only raw native arguments (JNIEnv*,jobject, and the function pointer). It has no information about which managed object owns thejobject, so it cannot keep that owner alive itself.A plausible failure sequence is:
instance.Handle.instance.jobjectis passed toGetObjectClass.instanceunreachable and process or finalize its JNI peer.jobjectand crashes inGetObjectClass.Adding:
extends the managed reference's live range through the entire native call. Mono must then preserve instance in a GC-tracked stack slot or callee-saved register, allowing the GC-safe transition to report it as a live root.
This is the same class of premature JNI handle-owner collection addressed by #12315. That PR fixes paths which can lead through
ValueManager.GetPeer()andCreatePeer()toJniEnvironment.Types.GetObjectClass().A useful next step would be to deploy a build containing #12315 and compare the
GetObjectClasscrash rate with the existing baseline.@jonathanpeppers, looks like its related to not keeping JNI references alive that gets passed down through the managed->native wrapper, do you plan to backport #12315?
jonathanpeppers commentedon Sep 10, 2026
I did the change for #12315 because CoreCLR GC seems to be more aggressive. Some of our customers that tested CoreCLR early found changes like this were needed (and actually correct).
@branomalovec does this problem go away in .NET 11? If so, we could look into taking this to .NET 10.
branomalovec commentedon Sep 10, 2026
@jonathanpeppers Not yet — we haven't run .NET 11 anywhere. Our fleet is
net10.0-android in production (~8k devices) and a preview build can't ship to it,
so I can't answer "does it go away" from where we sit today.
The harder problem is that a bench test can't answer it either. There's no
deterministic repro — it's ~330 events/week across ~290 distinct devices (~4% of
the fleet weekly). A local .NET 11 soak that comes back clean would only tell us
we failed to trigger a race we can't trigger on demand. Happy to run one against
net11.0-android as a smoke check if it's useful, but I wouldn't read much into a
negative result.
One thing worth settling before a backport: dotnet/runtime#12315 covers the paths through
ValueManager.GetPeer()/CreatePeer(). The IL scan in the issue found other managed
callers funnelling into the same shared wrapper — JNIEnv.InvokeConstructor,
JNIEnv.AssertCompatibleArrayTypes, JavaConvert.GetTypeMapping,
JniEnvironment.Types.GetJniTypeNameFromInstance. Are those covered as well, or
would a dotnet/runtime#12315-only backport leave some of them exposed?
jonathanpeppers commentedon Sep 10, 2026
GPT 6 Astra found a couple more:
But many models seem to find false positives on this, and I've had to argue with them. 😄
[Java.Interop] Keep JNI reference owners alive during calls (#12754)
lateralusX commentedon Sep 11, 2026
It will have effect on Mono as well, but since Mono is not as aggressive as CoreCLR when it comes to consider objects unreachable within a method, it will manifest much more frequently on CoreCLR compared to Mono. Since this doesn't look like a runtime issue, but related to managed object lifetime handled by caller, in this case Java.Interop code, I move this issue over to dotnet/android repro.
keegan-gehrig commentedon Oct 30, 2026
We're hitting this crash in production on .NET 10 and want to add data in support of a .NET 10 servicing backport of PR #12315 and #12754.
Environment
• .NET MAUI app, .NET 10.0.7 (SDK 10.0.203), Android workload 36.1.118, Mono runtime, arm64
• Default (Tarjan) GC bridge; Mono AOT off for Release (RunAOTCompilation=false)
• Sentry.Maui 6.2.0 with its native (NDK) integration
Signature
The top crash cluster in Google Play Android vitals is SIGSEGV in libart.so, frame 0 art::JNI::GetObjectClass, the same signature reported here. Play can't unwind past the next frame (managed code), and no frame in the trace is in our code. Two sample tombstones from separate crashes:
Sentry captured the same frame-0 signature independently, including on Android 12.
Scale (Google Play, 28 days to Oct 23, one app version)
• This signature is 74.2% of the app's Android crashes in that version: 217 users, 472 crash events.
• User-perceived crash rate is 4.47%, four times Play's 1.09% bad-behavior threshold. About 1,570 monthly active devices.
• Sessions (Sentry, 30 days): 23,835 of 68,221 Android sessions (35%) ended in a crash. Sentry's unsymbolicated libart.so reports include some Mono signal-handler noise, so treat this as an upper bound; the Play figures above are the conservative view.
Pattern
• Foreground: users see the app close on them.
• Across devices and OS versions: Android 12 through 17; Samsung Galaxy S22 to S25 and S24 Ultra, Google Pixel 10.
• On the main thread and on thread-pool threads.
• Usually within a minute of a data load or sync (median 49 seconds after the last logged action, in a sample of 184 crash events). Our sync code makes no JNI calls, but it allocates heavily, which fits a GC race that fires more often when the collector is busy.
• Started with our move from Xamarin.Forms to .NET 10 MAUI: first release 8/17, Play crash-rate warning 9/24, present in every release since. The Xamarin.Forms app never crossed Play's threshold.
What we've ruled out
• An app-level workaround: the handle is dropped inside Java.Interop and Mono.Android during framework calls (peer creation, type lookup, JavaAs, exception throw). GC.KeepAlive in app code can't cover those calls.
• AndroidEnableSGenConcurrent=false: that addresses the SGen worker crash (dotnet/maui #21479), not this one. bridge-implementation=old falls back to new on .NET 10, which doesn't target this race.
• PRs #12315 and #12754 aren't in workload 36.1.118, the latest .NET 10 Android release.
Why we can't show the .NET 11 result
We don't have a local repro; the crash shows only at production scale. Moving production to .NET 11 also means moving Android to CoreCLR, a full runtime change and regression cycle that puts .NET 11 evidence months out.
Ask
A .NET 10 servicing backport of PRs #12315 and #12754. If a build of the .NET 10 Android workload with those changes is available, we'll ship it to a staged rollout on Play and report the crash rate before and after here.
jonathanpeppers commentedon Nov 9, 2026
Hello all, could you try .NET 11 and find out if things have improved? It is using CoreCLR, so a completely different runtime.
Thanks!