runtime: # Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr ************ in tid **** (SGen worker)
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
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 53 (27 by maintainers)
@BrzVlad How are you building with the concurrent GC disabled?
Are you just doing it in the csproj configuration with
Or is there other build params/steps?
@IainS1986 That is correct.
@Th3L0x That is a completely unrelated issue. See https://github.com/dotnet/runtime/issues/106410 for workaround until we are able to investigate it.
@BrzVlad Replacing a shared library in the apk requires that you re-align and re-sign the archive, or it won’t install and run on the device/emulator. Signing process records sha256 hashes of the shared libraries. When you need to do that, ping us on Discord in the #android channel, we’ll help you out 😃
Also checking in to see if there’s anything I can do to help. This is killing our Google Play metrics for a number of apps that we have.
@feric-isc I didn’t verify the source code locations in your latest stack trace, but at the glance they look plausible 😃 @BrzVlad should be able to work with that 😃
@BrzVlad @grendello Ok I think I was able to get it. Here is the symbolized stack trace. Please let me know if this is what you’re looking for:
stacktrace_symbolized.txt
@grendello for your suggestion, I ran the llvm-readelf command. Here is the output: `>llvm-readelf --string-dump=.gnu_debuglink libmonosgen-2.0.so
String dump of section ‘.gnu_debuglink’: [ 0] libmonosgen-2.0.so.dbg [ 18] ….`
@BrzVlad I usually do it by hand using
llvm-addr2linebut yes,ndk-stackshould work fine. You can get the symbols by extractinglibmonosgen-2.0.sofrom the apk, then using thedotnet-symboltool (dotnet-symbol libmonosgen-2.0.so). This will place the debug symbols next to the code .so andndk-stackshould be able to symbolicate the trace.Don’t use the
mod-union-consistency-check, there seems to be some issues with it. Also note thatcollect-before-allocs,verify-before-allocsare absurdly heavy, maybe use them just for a few runs manually to see if they happen to report anything, I don’t think it would be worthwhile to stress test with it. I would say it is best to first run without any debug flags just to see whether the gc options might fix the crash and only afterwards attempt to run with gc flags on the crashing configurations.So some explicit configurations could be
evacuation-threshold=0,no-precleaningcheck-remset-consistencycheck-remset-consistency,collect-before-allocs=100When there are GC problems, the application can crash in a variety of ways, they are non-deterministic by nature. I am almost certain that the underlying issue is the same and based on comments on other issues it seems that the culprit is somewhere in the concurrent collector.
Note that I’m getting crashes with some of these debug options locally on some of our tests suites that are somewhat heavier on the GC. I will have to do a little bit of investigation to see whether they are false positives or not and see if these constraints from the debug options are respected in our own tests suites, before investigating anything on a mobile app.
Assuming we can’t reproduce this issue, the second approach I would take is to understand more or less what the application was doing when it crashed and then attempt to do more or less the same thing locally, with some different gc params / debug options, in the hope of catching some inconsistencies in the GC. I think an apk with the application with some instructions on what to do in the app could be useful. @grendello I am assuming one could easily unzip an apk, patch
libmonosgen-2.0.soand then zip it back to have the application run with custom runtime, right ?@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 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!