Skip to content

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

Merged
jamescrosswell merged 5 commits intomainfrom
jpnurmi/fix/android-ndk-preload
Apr 16, 2026
Merged

fix: prevent redundant native exceptions on Android/CoreCLR#5127
jamescrosswell merged 5 commits intomainfrom
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 │
           └──────────────┘     └───────────────┘     └────────┘

Reordering the signal handlers 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: Add network details for session replay on iOS by jamescrosswell in #4891
  • feat: Add option to exclude certain HTTP statuses from tracing by jamescrosswell in #5034

Fixes 🐛

  • fix: prevent redundant native exceptions on Android/CoreCLR by jpnurmi in #5127
  • fix: memory leak when profiling is enabled by jamescrosswell in #5133
  • fix: prevent redundant native exceptions on iOS by jpnurmi in #5126
  • fix: prevent redundant native exceptions on Android/Mono by jpnurmi in #4676
    • Note: opt in by setting options.Native.ExperimentalOptions.SignalHandlerStrategy to Sentry.Android.SignalHandlerStrategy.ChainAtStart

Dependencies ⬆️

Deps

  • chore(deps): update Java SDK to v8.39.0 by github-actions in #5137
  • chore(deps): update Native SDK to v0.13.7 by github-actions in #5136
  • chore(deps): update Cocoa SDK to v9.10.0 by github-actions in #5132
  • chore(deps): update Cocoa SDK to v9.9.0 by github-actions in #5115
  • chore(deps): update Java SDK to v8.38.0 by github-actions in #5124

🤖 This preview updates automatically when you update the PR.

Comment thread integration-test/android.Tests.ps1 Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.05%. Comparing base (e99c3d1) to head (2fe4c85).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5127      +/-   ##
==========================================
+ Coverage   74.04%   74.05%   +0.01%     
==========================================
  Files         501      501              
  Lines       18107    18107              
  Branches     3523     3523              
==========================================
+ Hits        13408    13410       +2     
+ Misses       3838     3837       -1     
+ Partials      861      860       -1     

☔ 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 2 times, most recently 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
Comment thread src/Sentry/Platforms/Android/SentrySdk.cs
Base automatically changed from feat/android-signal-handler-strategy to main April 14, 2026 02:56
@jpnurmi jpnurmi force-pushed the jpnurmi/fix/android-ndk-preload branch from 2a35e7a to 1fcad67 Compare April 14, 2026 06:53
web-flow and others added 2 commits April 16, 2026 14:15
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 changed the base branch from main to deps/scripts/update-java.ps1 April 16, 2026 14:18
@jpnurmi jpnurmi force-pushed the jpnurmi/fix/android-ndk-preload branch from 1fcad67 to 12cb11f Compare April 16, 2026 14:18
jpnurmi and others added 3 commits April 16, 2026 16:45
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keeps the source-tree Sentry.targets import out of the shared
integration-test/Directory.Build.targets so non-Android integration
tests (AOT, runtime, console) aren't affected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Android CoreCLR support starts with .NET 10; running the coreclr
cases on net9.0 would fail at build time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jpnurmi jpnurmi marked this pull request as ready for review April 16, 2026 16:27
Base automatically changed from deps/scripts/update-java.ps1 to main April 16, 2026 23:33
@jamescrosswell jamescrosswell merged commit 545ac31 into main Apr 16, 2026
45 checks passed
@jamescrosswell jamescrosswell deleted the jpnurmi/fix/android-ndk-preload branch April 16, 2026 23:39
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.

3 participants