Skip to content

fix: prevent redundant native exceptions on Android/CoreCLR#5127

Draft
jpnurmi wants to merge 2 commits intofeat/android-signal-handler-strategyfrom
jpnurmi/fix/android-ndk-preload
Draft

fix: prevent redundant native exceptions on Android/CoreCLR#5127
jpnurmi wants to merge 2 commits intofeat/android-signal-handler-strategyfrom
jpnurmi/fix/android-ndk-preload

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented Apr 9, 2026

Fixes duplicate native exceptions (#3954) on Android by reordering signal handlers to let .NET/CoreCLR handle managed exceptions first, and then chain real native exceptions to Sentry.

Before:

           ┌───────────────┐     ┌──────────────┐     ┌────────┐
Signal────>│ Sentry Native │────>│ .NET/CoreCLR │────>│ System │
           └───────────────┘     └──────────────┘     └────────┘

After:

           ┌──────────────┐     ┌───────────────┐     ┌────────┐
Signal────>│ .NET/CoreCLR │────>│ Sentry Native │────>│ System │
           └──────────────┘     └───────────────┘     └────────┘

This approach only works with CoreCLR (UseMonoRuntime=false, experimental in Android .NET 10.0+) for the time being.

With Mono, one will have to opt in for the "chain at start" signal handler strategy until the following fix has been released:

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features ✨

  • feat: native signal handler strategy on Android by jpnurmi in #4676

Fixes 🐛

  • fix: prevent redundant native exceptions on Android/CoreCLR by jpnurmi in #5127

🤖 This preview updates automatically when you update the PR.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.96%. Comparing base (02f59c1) to head (2a35e7a).
⚠️ Report is 34 commits behind head on feat/android-signal-handler-strategy.

Files with missing lines Patch % Lines
src/Sentry/Protocol/Envelopes/Envelope.cs 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                           Coverage Diff                            @@
##           feat/android-signal-handler-strategy    #5127      +/-   ##
========================================================================
- Coverage                                 73.99%   73.96%   -0.03%     
========================================================================
  Files                                       499      499              
  Lines                                     18067    18067              
  Branches                                   3519     3520       +1     
========================================================================
- Hits                                      13368    13364       -4     
- Misses                                     3839     3840       +1     
- Partials                                    860      863       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi jpnurmi force-pushed the jpnurmi/fix/android-ndk-preload branch from 57fd7bb to 7b2244a Compare April 9, 2026 18:44
@jpnurmi jpnurmi changed the title fix(android): preload NDK integration for CoreCLR fix: prevent redundant native exceptions on Android/CoreCLR Apr 9, 2026
@jpnurmi jpnurmi force-pushed the jpnurmi/fix/android-ndk-preload branch from 7b2244a to e5df035 Compare April 9, 2026 19:29
jpnurmi and others added 2 commits April 9, 2026 22:51
Enable the io.sentry.ndk.preload metadata so that
SentryNdkPreloadProvider installs sentry-native's signal handlers
before .NET/CoreCLR. This ensures the correct handler chain order
(.NET -> sentry-native -> debuggerd) where .NET handles managed
exceptions first, and native crashes chain to sentry-native.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jpnurmi jpnurmi force-pushed the jpnurmi/fix/android-ndk-preload branch from e5df035 to 2a35e7a Compare April 9, 2026 21:02
@jpnurmi jpnurmi changed the base branch from main to feat/android-signal-handler-strategy April 9, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant