Description
Description
While investigating the behavior of the crash reported in: #105245 on iOS device we noticed that such error does not:
- Produce any useful information in the
Console.app
- It did not generate a crash report on a device
Repro
- Install official .NET 9 preview 6 release
- Install MAUI workloads
- Create a MAUI template app
- Build/run it on a physical device in
Debug
mode:
dotnet build -f net9.0-ios -r ios-arm64 -t:Run -p:_DeviceName=XXXXXX
Console.app
shows only that the program exited:
default 14:14:51.131793+0200 SpringBoard [app<com.companyname.myapp(80F7F2DD-E9BB-43D8-AB25-7A0DE1A64558)>:6714] Process exited: <RBSProcessExitContext| voluntary>.
- No crash logs are generated on a device
Investigation
As initially assumed, the crash was not caused by asserting from the runtime (where we abort()
properly), but instead the code was trying to read from an invalid memory address (something like 0xa8) so SIGSEGV
was raised.
The mono's signal handler catches this, but does not remove it self as a SIGSEGV
handler when it starts handling the signal.
After the handling is done, the handler returns, but the same signal is caught again and on second handling the program exits out with -1 in case of double faulting:
runtime/src/mono/mono/mini/mini-posix.c
Lines 789 to 792 in fdb7415
This causes the app to silently exit not including any information about the crash.
Additionally, the messages from the signal handler (like information about the native and managed stack traces) that are using
g_async_safe_printf
are not shown in the system log.
FWIW In the signal handler we do unregister the runtime for some signals, but not for SIGSEGV
:
runtime/src/mono/mono/mini/mini-exceptions.c
Lines 2932 to 2942 in d606c60
Proposal
- Investigate if we can unregister the
SIGSEGV
handler if we've detected that the signal it's not coming from managed code (to distinguishNullReferenceException
) - Try using a platform specific logging mechanism so that messages from the signal handler end up in the system log when a fatal error occurs
PS Thanks @lambdageek for assistance