runtime: [Android] App crashing with condition `xref_count == xref_index' not met
Description
This is happening when using shell navigation to navigate to a bunch of pages. Unfortunately I was unable to reproduce it on a simpler project to post. So I’m uncertain exactly what’s causing this. However, it was working on MAUI version 8.0.40 and broke on subsequent versions.
I was able to reproduce on the Android emulator
Others have posted about this as well: https://github.com/dotnet/maui/issues/23827 https://github.com/dotnet/maui/discussions/23634 https://github.com/dotnet/maui/discussions/23826
Steps to Reproduce
See description
Link to public reproduction project repository
No response
Version with bug
8.0.60 SR6
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.40 SR5
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No
Relevant log output
[namix.mobileapp] * Assertion at /__w/1/s/src/mono/mono/metadata/sgen-tarjan-bridge.c:1174, condition `xref_count == xref_index' not met, function:processing_build_callback_data, xref_count is 1101 but we added 1096 xrefs
[libc] Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 8651 (namix.mobileapp), pid 8651 (namix.mobileapp)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 5
- Comments: 64 (31 by maintainers)
Commits related to this issue
- fix: Use "new" android bridge by default Follows the recommendation from https://github.com/dotnet/runtime/issues/106410#issuecomment-2291508507 — committed to unoplatform/uno.templates by jeromelaban 2 years ago
- Add repro for https://github.com/dotnet/runtime/issues/106410 — committed to filipnavara/runtime by filipnavara 2 years ago
The fix is going to be released with .NET 9.0.5 (±May 13, 2025).
We were able to fix the issue using the suggestion above. We added an Environment.txt file with the following:
MONO_GC_PARAMS=bridge-implementation=newAnd added this to the project file:
The current target release is 9.0.6, so roughtly June 10, 2025.
Note that the fix in servicing had to be reverted because we hit an assertion in testing. That was fixed by https://github.com/dotnet/runtime/pull/114637, but it caused us to be a bit more careful before we take the fix in. If https://github.com/dotnet/runtime/pull/114682 goes in, that’ll apply to 9.0.6.
I’ll reopen the issue for better tracking.
A fix is being worked on. Until it is released, you can use the workaround in https://github.com/dotnet/runtime/issues/106410#issuecomment-2391391866.
.NET 9.0.7 fixed this for us. App used to crash when working with images (usually during or after uploading). Doesn’t crash anymore. Thanks!
@ dotnet-runtime maintainers: how risky would it be - in your opinion - to use a daily build for a production app given the current state of 9.x?
We really need this fix asap and the 9.0.7 release time doesn’t meet our deadlines.
If the backport of tests is not too complicates (like needed lot of other infra changes) then I would also pick it up. As you noted we will maintain 9.0 for at least another year, so we should be able to validate that it works well.
I’d prefer backporting the tests as well so we’re sure it works in the 9.0 state-of-the-world
Unfortuantely, no. It’s likely that my fix will get reviewed this week. However, even if it gets accepted as-is we will need to go through a backport process to fix it in .NET 9. Once we are at that point I can make some estimates.
It’s NOT the culprit. The bug is in the MonoVM GC bridge. It just happens to be triggered by certain shapes of the object reference graph, so some code may be more prone to trigger it.
So when I added this:
My code now shows this:
[DOTNET] MONO_GC_PARAMS: bridge-implementation=newDebugging seems to be running better now without crashing but I am still testing. It was really slow starting the debugger tho.
I am also facing this:
xref_count == xref_index' not met, function:processing_build_callback_data, xref_count is 572 but we added 563 xrefs [monodroid] * Assertion at /__w/1/s/src/mono/mono/metadata/sgen-tarjan-bridge.c:1176, conditionxref_count == xref_index’ not met, function:processing_build_callback_data, xref_count is 572 but we added 563 xrefs [monodroid] Abort at mono-log-adapter.cc:46:3 (‘static void xamarin::android::internal::MonodroidRuntime::mono_log_handler(const char *, const char *, const char *, mono_bool, void *)’)Unfortunatly I don’t have a simplified repro
Using:
.NET MAUI 9.0.5