Repository navigation
Description
Android framework version
net8.0-android
Affected platform version
.NET 8.0.100, .NET 8.0.303
Description
Our Android application started to crash randomly 3 months ago when we upgraded it to .net6.
We tried to add more logging, analyze the logcat, reproduce... but all in vain.
In an attempt to stabilize the app, we have upgraded to .net8.0-android and the number of crash was significantly reduced.
This problem happens on different kind of tablets, and we excluded the idea that it could come from firmware or hardware
because they did not change and with .net framework (Xamarin) everything was running smoothly (1 crash rarely vs hundreds per day now).
Our dev and testing team (qa) are not able to reproduce the problem. Looking at the logs (SIGSEGV_Samples_logcat-with-symbols.txt), we see that all of the SIGSEGV (SEGV_MAPERR) happens on the SGen worker thread but give different backtraces.
At the end of the log file, you’ll find a SIGABRT from SGen. We’ve kept it there for reference, in case it’s related to the SIGSEGV issues.
We used dotnet-symbol to retrieve a debug version of libmonosgen-2-0.so (with symbols). Then we run ndk-stack on our
logcat to symbolize the backtraces.
Application catches nothing. So we don't have any other traces to give from it. The logcat contains the most detailled
ones we have.
FYI, we did split our crashes into 3 categories, we're not sure that they related to the SIGSEGV...
but to give you all data, the other 2 are :
- Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid ***** (|ANR-WatchDog|), pid ***** (com.isaac.onthego)
- Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid ***** (enableInternal), pid ***** (com.android.nfc)
What we tried :
-
Reproducing by running our acceptance tests on the tablet
-> Nothing happens unless we run the day long tests and it's very rare. It does not give more information than what we have in production. -
Upgrading .net version (from 8.0.100 to 8.0.303)
-> Nothing changed. -
Revert to .Net Framework (Xamarin)
-> We did it in order to identify if it's related to our changes or the framework. And it worked !!!
The number of crash were back to normal (before .net6 and .net8). -
*** EDIT *** We also tried to disable trimming by settings
<PublishTrimmed>false</PublishTrimmed>in all of our .csproj.
-> Our APK was a little bit heavier (of course) and no changes in number of crashes..
What we are still probing :
- Disabling concurrency on Mono Garbage collector and change the bridge-implementation to old
-> We’ve seen numerous issues and discussions about the stability of SGen. We are hoping that this change can make a difference, as the backtraces seem to point to a problem that could be within it. If this works, it could allow us to stay with .net8 until a fix is found.
Thank you in advance for your help. We will remain vigilant if you need more details.
Steps to Reproduce
Unfortunetaly we are unable to reproduce the problem in step by step as it appears randomly on production.
Did you find any workaround?
Currently, reverting to the .Net Framework appears to be effective for us.
Relevant log output
See attached files of the description
Activity
grendello commentedon Jul 24, 2024
@dcrespo-isaac thanks for the logs! They universally show that the issue is somewhere in the MonoVM's GC (SGEN), so I think the issue belongs in
dotnet/runtime. Would you happen to still have the logs that haveSIGABRTin them? The reason I ask is that they would contain more information before the native stack trace is dumped. The information will contain the actual assertion message logged by MonoVM - and this message is crucial to understanding what's going on. If you could share these logs, or scour them for any log lines containing any assertions coming from MonoVM and paste them here, it would be very helpful. Thanks!akoeplinger commentedon Jul 24, 2024
@BrzVlad looks like a GC issue
grendello commentedon Jul 24, 2024
@dcrespo-isaac Scan the logs for messages containing strings similar to
* Assertion atwhich are tagged either with an empty string,DOTNETor a fragment of your application's ID. The message will also contain a file path which should havemonocomponent in it.dcrespo-isaac commentedon Jul 24, 2024
Thank you for the triage.
I've found the logcat I had analyzed for the SIGSEGV errors. In the logcat-Assertion.txt, you'll find two samples of SIGABRT preceded by :
Assertion at /__w/1/s/src/mono/mono/metadata/object.c:4410, condition `is_ok (error)' not met, function:mono_unhandled_exception_internal, (null) assembly:System.Private.CoreLib.dll type:ArgumentNullException member:(null)Additional notes:
ANR_WatchDogthread and other times on what appears to be the main threadcom.isaac.onthego.-> We attempted to identify a pattern between SIGSEGV and SIGABRT, but found nothing significant. This means that they don’t precede or follow each other in any particular way.
I will continue to update the issue if I encounter any other assertion errors.
lambdageek commentedon Jul 30, 2024
@dcrespo-isaac I don't have any insight for the SIGSEGV, but for SIGABRT - does your app have a
AppDomain.CurrentDomain.UnhandledExceptionevent handler installed? the assertion on object.c:4410 looks like it's due to an unhandled null reference exception during the execution of the unhandled exception handler.dcrespo-isaac commentedon Jul 31, 2024
Hi @lambdageek,
First and foremost, thank you for your response. It is greatly appreciated. We have identified the origin of the SIGABRT:
Regarding this open issue, we continue to experience problems with SIGSEGV, which is the primary subject of this issue and, regrettably, the cause of the majority of our crashes.
We are currently deploying our reverted version to Xamarin, as it has proven to be significantly more stable. We will remain vigilant for any responses, fixes, or requests for additional information regarding this issue.
47 remaining items
BrzVlad commentedon Jul 11, 2025
@ahoffmandevelopment We would need a symbolicated stacktrace first to be able to at least understand what type of failure this is. Maybe you would have more success with this ?
feric-isc commentedon Jul 14, 2025
@BrzVlad Are you able to confirm if you can or cannot work with my symbolicated traces? There seemed to be ambiguity between your comment and those of others? If not I can try again
BrzVlad commentedon Jul 14, 2025
Sorry if I was ambiguous. Unfortunately the stack traces are not really useful since the resolved symbols are incorrect.
feric-isc commentedon Jul 14, 2025
Hello @BrzVlad . Here are 2 additional symbolized stacktraces (with their non-symbolicated files they were generated from).
sigsegv1.txt
sigsegv1_symbolized.txt
sigsegv2.txt
sigsegv2_symbolized.txt
Here is what I did to symbolicate. Let me know if something is not ok.
feric-isc commentedon Aug 11, 2025
Hi @BrzVlad. Are these traces better?
BrzVlad commentedon Aug 12, 2025
The stacktraces are definitely correct this time, thanks for taking the time to symbolicate the reports. There are no symbols for
libc.soandlibart.soso I can't be 100% that there are no other issues somewhere else outside of the runtime. I've seen crashes before in the art GC or in other places. At least we know there no crashes in the .NET runtime.Having said that, if we are to assume that the first reported thread is the one that is crashing (I think this should be the case but I don't have full trust in these reports), this points to a null pointer dereference in managed code crashing the application. This normally should be impossible, a NRE should be thrown, unless the signal handlers have been tampered with. We've recently uncovered such an issue, fixed by #118085. So if your application uses
Process.StartorSystem.Net.NetworkInformation.Ping, this means you are hitting the above mentioned issue.feric-isc commentedon Aug 15, 2025
Thanks for your feedback @BrzVlad . We checked and we don't seem to use Process.Start or System.Net.NetworkInformation.Ping. Is that something you deduced from our stacktraces? If we don't use them, do you still think it could be related to the issue you mentioned? I seem to see that it has been backported in .NET9. So if we update to latest of .NET9 and we still have the issue, what then? We are planning to do so in the next month or so...
BrzVlad commentedon Aug 20, 2025
The version containing the mentioned fix will be 9.0.10. So it will take a while before you can try it out (I think around 1.5 months). To me it just feels like the only plausible explanation, but I wouldn't be overly confident about it. In order to validate this in the meantime, you could try to use the following environment flag:
MONO_DEBUG=explicit-null-checks(this avoids usage of signals when throwing NRE). You should be able to tweak the environment by adding the value to a new file and then include this file in the build as an android environment file. For example:You might want to check at runtime with
Environment.GetEnvironmentVariableto see that the env var is set correctly, there have been some issues in the past (only with debug builds I think).bnSonic commentedon Nov 20, 2025
I cannot say too much - but I see these crashes in the google play console (it raises the crashes to above 2% so I'm getting warnings from google)
currently I have no idea if there is more information available on the google console site …
I'm using the .net9 / maui 9.0.120 versions
slepmog commentedon May 11, 2026
Also plagued by this. As soon as we were forced to port from Xamarin to .net9.0-android, these started.
The entire warehouse operation is affected by this, and we cannot go back to Xamarin because that no longer even builds, because of the minimum API restriction.
BrzVlad commentedon May 11, 2026
@slepmog It's not clear if your crash is related. Could you upgrade to latest .net 10 first ?
slepmog commentedon May 11, 2026
@BrzVlad I thought it was related because it's the same type of crash (signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)) in the same lib (libmonosgen-2.0.so) with the same no way to catch it (the process is killed by the OS instead of triggering our
try/catch).And we would need to switch to VS 2026 to try .net 10.
In the past 10 years our experience has been that with .NET Android development, when you try to work with an existing project in a later version of Visual Studio, it breaks in unfathomable ways and fails to compile with hundreds of errors that don't make sense, so switching the VS version has always been a full-time, one-way, porting project.
slepmog commentedon Nov 20, 2026
We have done additional data collection and analysis (with AI this time), and the conclusion seems to be that
mono_guid_to_string_minimalcrashes when there is a Reflection.Emit/DispatchProxy frame on its stack, because that frame has a null GUID, andmono_guid_to_string_minimalcrashes when it tries to read it for its log formatting purposes, thus hiding the original exception.The flow is:
OnCreate(the client code generated with dotnet-svcutil)mono_debug_print_stack_frametries to format our thread's stack, which is in the middle of a web service call via a generated DispatchProxy method, and crashes because there is no GUID heap in a generated DispatchProxy method.I do not feel competent enough to judge if this indeed belongs to this issue or should be a separate one.
BrzVlad commentedon Nov 20, 2026
@slepmog .NET11 was just released the other day and we unified the runtime in this release. MAUI now uses CoreCLR. Could you give it a try, whether the bug is fixed in the new release ? Sounds like it should be easy to reproduce by just making the call hang.
slepmog commentedon Nov 20, 2026
@BrzVlad We have a net9.0-android application, not MAUI (and the OP has net8.0-android). And same VS version concerns apply like before :)
Then again, it would appear that .NET 9 went out of support 10 days ago which I have missed. So I guess this finding is a bit late.