Skip to content

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Sep 18, 2025

📜 Description

Prevent the Cocoa SDK from capturing managed .NET exceptions.

First of all, we need to avoid overriding Mono's Mach exception port for EXC_BAD_ACCESS and EXC_ARITHMETIC to allow handling the respective Unix signals. Secondly, Sentry's signal handler has to first invoke Mono's signal handler to give it a chance to convert it into a managed exception and redirect execution into the managed runtime’s exception handling machinery, so that managed code can catch and process the exception as if it were a normal .NET exception. Finally, Sentry's crash capturing kicks in only if we do not detect instruction or stack pointer modifications in the context.

💡 Motivation and Context

Fixes a long-standing issue with redundant crash events with Sentry.NET on iOS:

See also similar Sentry Native changes for Android:

💚 How did you test it?

  1. With the newly developed Sentry .NET integration test for iOS:
  2. Manually with Sentry.Samples.Maui in Sentry.NET:

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.070%. Comparing base (1655116) to head (be528ee).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ash/Recording/Monitors/SentryCrashMonitor_Signal.c 0.000% 24 Missing ⚠️
...ording/Monitors/SentryCrashMonitor_MachException.c 25.000% 3 Missing ⚠️
Sources/Sentry/PrivateSentrySDKOnly.m 50.000% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6193       +/-   ##
=============================================
- Coverage   85.169%   85.070%   -0.100%     
=============================================
  Files          452       452               
  Lines        27659     27696       +37     
  Branches     12117     12128       +11     
=============================================
+ Hits         23557     23561        +4     
- Misses        4054      4091       +37     
+ Partials        48        44        -4     
Files with missing lines Coverage Δ
Sources/Sentry/SentryCrashIntegration.m 100.000% <100.000%> (ø)
...entryCrash/Recording/Monitors/SentryCrashMonitor.c 80.952% <100.000%> (+0.624%) ⬆️
...SentryCrash/Recording/Tools/SentryCrashCPU_arm64.c 100.000% <100.000%> (ø)
Sources/Sentry/PrivateSentrySDKOnly.m 81.818% <50.000%> (-0.535%) ⬇️
...ording/Monitors/SentryCrashMonitor_MachException.c 35.123% <25.000%> (-0.171%) ⬇️
...ash/Recording/Monitors/SentryCrashMonitor_Signal.c 49.253% <0.000%> (-9.675%) ⬇️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1655116...be528ee. Read the comment docs.

jpnurmi added a commit to getsentry/sentry-dotnet that referenced this pull request Sep 18, 2025
This reverts "Use pre-built version of sentry-cocoa SDK (#3727)"
commit d179ec9 and restores the
modules/sentry-cocoa Git module checked out at:
getsentry/sentry-cocoa#6193
@jpnurmi jpnurmi force-pushed the jpnurmi/mono-interop branch 2 times, most recently from 2f90356 to ed98b04 Compare September 18, 2025 11:46
@github-actions
Copy link
Contributor

github-actions bot commented Sep 18, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1216.42 ms 1251.93 ms 35.52 ms
Size 23.75 KiB 1.00 MiB 1000.37 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4a7a005 1229.15 ms 1243.35 ms 14.20 ms
ae7be93 1236.24 ms 1258.18 ms 21.94 ms
b9ceffb 1222.57 ms 1247.96 ms 25.39 ms
884b224 1221.11 ms 1255.88 ms 34.77 ms
2a9a505 1221.49 ms 1238.49 ms 17.00 ms
00d9740 1223.53 ms 1249.75 ms 26.22 ms
e8f9a1d 1229.02 ms 1264.17 ms 35.15 ms
6502818 1229.08 ms 1245.46 ms 16.37 ms
5712478 1220.10 ms 1239.69 ms 19.59 ms
8da82b4 1220.08 ms 1248.24 ms 28.16 ms

App size

Revision Plain With Sentry Diff
4a7a005 23.75 KiB 979.96 KiB 956.22 KiB
ae7be93 23.75 KiB 879.24 KiB 855.49 KiB
b9ceffb 23.75 KiB 969.07 KiB 945.32 KiB
884b224 23.75 KiB 879.55 KiB 855.80 KiB
2a9a505 23.75 KiB 874.46 KiB 850.71 KiB
00d9740 23.75 KiB 938.32 KiB 914.57 KiB
e8f9a1d 23.75 KiB 969.78 KiB 946.04 KiB
6502818 23.75 KiB 959.45 KiB 935.70 KiB
5712478 23.75 KiB 969.28 KiB 945.54 KiB
8da82b4 23.75 KiB 913.63 KiB 889.88 KiB

Previous results on branch: jpnurmi/mono-interop

Startup times

Revision Plain With Sentry Diff
f651762 1232.57 ms 1259.68 ms 27.11 ms
d171c8f 1226.86 ms 1256.95 ms 30.09 ms
1666de5 1208.65 ms 1245.50 ms 36.85 ms

App size

Revision Plain With Sentry Diff
f651762 23.75 KiB 975.29 KiB 951.55 KiB
d171c8f 23.75 KiB 1.02 MiB 1016.31 KiB
1666de5 23.75 KiB 1.01 MiB 1016.19 KiB

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Sep 18, 2025

Screen.Recording.2025-09-18.at.11.54.52.mov

@jpnurmi jpnurmi changed the title [WIP] fix: interop with managed Mono/CoreCLR runtimes [WIP] fix: interop with managed .NET runtimes Sep 29, 2025
@jpnurmi jpnurmi force-pushed the jpnurmi/mono-interop branch from ed98b04 to 8559ea9 Compare October 28, 2025 12:47
@jpnurmi jpnurmi changed the title [WIP] fix: interop with managed .NET runtimes [WIP] fix: AOT interop with managed .NET runtimes Oct 28, 2025
@jpnurmi jpnurmi changed the base branch from main to v8.x October 28, 2025 12:58
@jpnurmi jpnurmi force-pushed the jpnurmi/mono-interop branch from db30de0 to dd33f14 Compare October 28, 2025 16:20
@jpnurmi jpnurmi changed the base branch from v8.x to main October 28, 2025 16:20
@jpnurmi jpnurmi force-pushed the jpnurmi/mono-interop branch from dd33f14 to e51c82e Compare October 29, 2025 13:13
@jpnurmi jpnurmi changed the title [WIP] fix: AOT interop with managed .NET runtimes fix: AOT interop with managed .NET runtimes Nov 3, 2025
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.

2 participants