Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use MarshalManagedExceptionMode.UnwindNativeCode when building for Mono on net8.0 and earlier #3912

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- .NET on iOS: Add experimental EnableAppHangTrackingV2 configuration flag to the options binding SDK ([#3877](https://github.com/getsentry/sentry-dotnet/pull/3877))
- Added `SentryOptions.DisableSentryHttpMessageHandler`. Useful if you're using `OpenTelemetry.Instrumentation.Http` and ending up with duplicate spans. ([#3879](https://github.com/getsentry/sentry-dotnet/pull/3879))

### Fixes

- Use MarshalManagedExceptionMode.Default on CoreCLR ([#3912](https://github.com/getsentry/sentry-dotnet/pull/3912))
jamescrosswell marked this conversation as resolved.
Show resolved Hide resolved
jamescrosswell marked this conversation as resolved.
Show resolved Hide resolved

### Dependencies

- Bump Native SDK from v0.7.17 to v0.7.18 ([#3891](https://github.com/getsentry/sentry-dotnet/pull/3891))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,15 @@
</ItemGroup>
</Target>

<!--
Ensure the AppDomain.CurrentDomain.UnhandledException gets triggered - see:
https://github.com/xamarin/xamarin-macios/issues/15252

Not supported on the CoreCLR or NativeAOT - see:
https://github.com/xamarin/xamarin-macios/blob/0a81da28e4217624a54ccb83541e1eb8ba651fca/runtime/runtime.m#L2480-L2491
-->
<PropertyGroup Condition="'$(UseMonoRuntime)' == 'true'">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also restrict this to net8.0 since this issue has been fixed in net9.0 on MONO

<MtouchExtraArgs>--marshal-managed-exceptions=unwindnativecode</MtouchExtraArgs>
</PropertyGroup>

</Project>
6 changes: 4 additions & 2 deletions src/Sentry/Platforms/Cocoa/SentrySdk.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Sentry.Cocoa;
using Sentry.Cocoa.Extensions;
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.PlatformAbstractions;

// ReSharper disable once CheckNamespace
namespace Sentry;
Expand All @@ -10,10 +12,10 @@ public static partial class SentrySdk
private static void InitSentryCocoaSdk(SentryOptions options)
{
options.LogDebug("Initializing native SDK");
// Workaround for https://github.com/xamarin/xamarin-macios/issues/15252
ObjCRuntime.Runtime.MarshalManagedException += (_, args) =>
{
args.ExceptionMode = ObjCRuntime.MarshalManagedExceptionMode.UnwindNativeCode;
// This MAY be overriden in Sentry.Bindings.Cocoa.targets
options.LogDebug($"MarshalManagedExceptionMode: {args.ExceptionMode}");
};

// Set default release and distribution
Expand Down
Loading