Open tipa opened 7 months ago
Hey @tipa, thanks for raising this. Could you provide us with some debug logs from the SDK so we can see what's going on?
Sure, I see these logs before the crash, during initialization:
Debug: Initializing Hub for Dsn: '...'.
Debug: This looks like a standard JIT/AOT application build.
Debug: Starting BackgroundWorker.
Debug: Registering integration: 'AutoSessionTrackingIntegration'.
Debug: BackgroundWorker Started.
Debug: Registering integration: 'AppDomainUnhandledExceptionIntegration'.
Debug: Registering integration: 'AppDomainProcessExitIntegration'.
Debug: Registering integration: 'SentryDiagnosticListenerIntegration'.
Info: DiagnosticSource Integration is disabled because tracing is disabled.
Debug: Registering integration: 'SystemDiagnosticsMetricsIntegration'.
Info: System.Diagnostics.Metrics Integration is disabled because no listeners are configured.
And then when I trigger the crash:
Debug: Triggering a deliberate exception because SentrySdk.CauseCrash(CrashType.Native) was called
An unhandled exception of type 'System.AccessViolationException' occurred in Sentry.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
You can reproduce it easily using this example: TestException.zip
Thanks for the repro and logs! Much appreciated!
I can definitely reproduce this... managed exceptions get caught by the global exception handler that Sentry wires up. This particularly native exception crashes the app, bypassing the global exception handler (and any other exception handling I try to setup).
I've tried surrounding the code in a simple try..catch
, but the catch never executes. I've tried setting up a custom SynchronizationContext but the exception never gets posted. I'm not sure if it's possible to catch these kinds of exceptions in WinUI.
Sorry for the delay and the misleading CauseCrash
utils. Unfortunately, the SDK does not support native crashes outside of AOT. We're going to guard the "demo" by a check and log instead of doing nothing.
@bruno-garcia tried adding and providing native support for regular JIT compiled applications over here https://github.com/getsentry/sentry-dotnet-minidump/issues/1 but that ran into a whole lot of issues.
@bruno-garcia tried adding and providing native support for regular JIT compiled applications over here https://github.com/getsentry/sentry-dotnet-minidump/issues/1 but that ran into a whole lot of issues.
To be clear it worked, but not the way you'd take the most value out of it. For example, there was no C# function names. I only saw C++ code, seemed like JIT generated code and less user-written code and no C#->C stack traces. SO it would require more work to get good support
I'm reopening this because we need to support capturing crashes in any sort of app. So this is a valid feature request imo
Package
Sentry
.NET Flavor
.NET
.NET Version
8.0.2
OS
Windows
SDK Version
4.2.1
Self-Hosted Sentry Version
No response
Steps to Reproduce
Sentry.SentrySdk.CauseCrash(Sentry.CrashType.Native)
Expected Result
Crash is being reported to sentry.io
Actual Result
No crash is being reported (but app crashes with
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt
). Happens both in debug as well as in Release mode