feat(android): allow NDK preload for .NET/CoreCLR#1613
Open
feat(android): allow NDK preload for .NET/CoreCLR#1613
Conversation
|
8fb200b to
593a225
Compare
Add sentry__backend_preload() for installing signal handlers before sentry_init(). For the inproc backend on Unix/Android, this allows establishing the correct signal handler chain order when another runtime (e.g. Mono/.NET) installs its own handlers later. - Backend dispatch: sentry__backend_preload() (no-op for non-inproc) - Extracted install_signal_handlers() with idempotency flag - Preload fallthrough: if handler thread not ready, invoke previous handler - NDK: SentryNdkPreloadProvider ContentProvider with high initOrder for early signal handler installation before Mono runtime - NDK: Java/JNI preload() method on SentryNdk Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Mono: chain-at-start (preload requires dotnet/runtime#125835) - CoreCLR: preload (chain-at-start blocked by libsigchain) - Auto-build the NDK AAR for preload tests
…preload When preloaded, skip handler teardown on sentry_close() so the runtime's handler chain remains intact for subsequent sentry_init(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
593a225 to
750c178
Compare
Fixes unused variable warning on Windows. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents infinite loop when the previous handler is SIG_DFL: without resetting, raise() re-enters sentry's handler due to SA_NODEFER. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The refactoring into install_signal_handlers() lost the error return. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
In practice, the process is about to die (SIG_DFL on a fatal signal), so this state is never observed. But clear it anyway for consistency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

.NET 10.0 added support for CoreCLR on Android (experimental). Unlike with the Mono runtime, where we're stuck with
CHAIN_AT_START(dotnet/runtime#125835), with CoreCLR we can already reorder the signal handlers to the preferred order:This gives the .NET runtime a chance to process managed .NET exceptions without Sentry Native stepping on its toes. This is much safer than
CHAIN_AT_START, and will be automatically enabled (io.sentry.ndk.preload=true) by Sentry.NET when targeting Android .NET 10.0 or later with CoreCLR.Changes
Add
sentry__backend_preload()for installing signal handlers beforesentry_init(). For the inproc backend on Unix/Android, this allows establishing the correct signal handler chain order when another runtime (e.g. Mono/.NET) installs its own handlers later.sentry__backend_preload()(no-op for non-inproc)install_signal_handlers()with idempotency flagSentryNdkPreloadProvidercontent provider with high init order for early signal handler installation before the CoreCLR runtimepreload()method on SentryNdkSee also