Skip to content

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Sep 18, 2025

📜 Description

WIP: 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. Secondly, the Sentry's signal handler first invokes 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 and only if we do not detect IP/SP 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. Manually with Sentry.Samples.Maui in Sentry.NET:
  2. With the newly developed Sentry .NET integration test for iOS:

📝 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

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3889 1 3888 52
View the top 1 failed test(s) by shortest run time
iOS_SwiftUI_UITests.LaunchUITests::testCaptureErrorReturnsValidId
Stack Traces | 0s run time
.../iOS-SwiftUI/iOS-SwiftUI-UITests/LaunchUITests.swift:56 - Failed to tap "Capture Error" Button: Timed out while evaluating UI query.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1232.57 ms 1259.68 ms 27.11 ms
Size 23.75 KiB 975.29 KiB 951.55 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7c7ac56 1225.90 ms 1250.22 ms 24.33 ms
8ea5293 1242.70 ms 1262.25 ms 19.55 ms
35c962f 1207.61 ms 1235.90 ms 28.29 ms
aa98fe8 1227.69 ms 1253.18 ms 25.50 ms
339539a 1219.58 ms 1254.63 ms 35.05 ms
0ac4c65 1236.85 ms 1267.84 ms 30.98 ms
6ee4973 1228.42 ms 1252.26 ms 23.84 ms
b13e93a 1236.24 ms 1247.33 ms 11.08 ms
2e79f5f 1220.53 ms 1249.35 ms 28.82 ms
5ae9ff1 1222.31 ms 1250.96 ms 28.65 ms

App size

Revision Plain With Sentry Diff
7c7ac56 23.75 KiB 902.49 KiB 878.74 KiB
8ea5293 23.75 KiB 852.24 KiB 828.49 KiB
35c962f 23.75 KiB 854.77 KiB 831.02 KiB
aa98fe8 23.75 KiB 891.01 KiB 867.26 KiB
339539a 23.75 KiB 968.24 KiB 944.50 KiB
0ac4c65 23.75 KiB 968.24 KiB 944.50 KiB
6ee4973 23.75 KiB 896.53 KiB 872.79 KiB
b13e93a 23.75 KiB 855.37 KiB 831.62 KiB
2e79f5f 23.75 KiB 928.87 KiB 905.12 KiB
5ae9ff1 23.74 KiB 971.82 KiB 948.08 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
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