-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
fix: [iOS / Native AOT] - prevent use of unsupported marshalling behaviour #3729
base: main
Are you sure you want to change the base?
Conversation
…dException` as a replacement for ExceptionMode
…lManagedException` to disable MarshalException settings
…bleMarshelManagedException
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
… MarshalManagedException event if compiled with Native AOT
That link is interesting... it seems to imply this setting could be controlled at build time, rather than runtime (what we're doing)... so it might be possible to set this automatically to the appropriate value via our transitive build script rather than waiting until runtime. If we are going to do it at runtime, it might be possible to pick an appropriate value automatically based on whether or not the user's application is compiled AOT or not (rather than hoping they configure the right value via the native options). We have an |
Looking at the implementation of AotHelper .IsAOT, I got the same impression. Should we do
I like this idea |
…aviour: move the AOT check to compilation
src/Sentry.Bindings.Cocoa/buildTransitive/Sentry.Bindings.Cocoa.targets
Outdated
Show resolved
Hide resolved
… compilation instead of runtime
There are a few more hoops to jump through before you can do this right? You have to setup a provisioning profile for the app in the apple developer portal first? I'm just waiting for Apple to renew my annual membership to the developer portal so I can test. |
maybe? I'm not sure. I think Xcode creates a temporary one you can also use a simulator I think, btw |
is this waiting on validation? Can I help? or we put an alpha out and as folks reporting the issue? |
Yes @jamescrosswell is going to run some tests to validate this.
I think it would be a good idea so James doesn't have to jump through hoops to test this, and I can also create a repo. |
Sorry for the delay. I've been trying to resolve #3764 (which is blocking this PR and anything else that targets |
src/Sentry.Bindings.Cocoa/buildTransitive/Sentry.Bindings.Cocoa.targets
Outdated
Show resolved
Hide resolved
src/Sentry.Bindings.Cocoa/buildTransitive/Sentry.Bindings.Cocoa.targets
Outdated
Show resolved
Hide resolved
…a.targets Co-authored-by: James Crosswell <[email protected]>
@bricefriha I finally carved out some time to setup a provisioning profile etc. so that I can test this. At the moment, I'm not able to publish this to test though - I'm running into trim analysis errors like:
This may be unrelated to your PR and more related to the fact that we bumped to net9.0... it's coming from the source generators, which is a bit odd. We might be referencing the wrong version of something. It does, however, still prevent me from being able to test this 😞 |
That shouldn't be related because you should at least be able to publish the app entirely. I would try again with .net8.0 (for troubleshooting sake) |
UpdateI experience the same issue now with .net9 |
Still having difficulty testing this, unfortunately... due to challenges publishing an AOT compiled application to iOS. When targeting net8.0 I ran into this: And I couldn't get publishing going using Xcode 16.2 Beta 3. I think we might need to wait for the official 16.2 release as there's only so much time I can burn on fiddling with tooling that is constantly changing. When targeting net9.0 I ran into this: Eventually, we're going to resolve one/both of the above though and we can finally test and release this fix. |
This has been addressed now with the release of Xcode 16.2.
Currently blocked by a bug in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bricefriha I'm not sure if you want to finish this PR or not.
I managed to test it by ignoring the trim warnings (setting <NoWarn>$(NoWarn);IL3053</NoWarn>
in the csproj file).
However I didn't see any noticeable difference between the stack traces with MarshalManagedExceptionMode.UnwindNativeCode
and MarshalManagedExceptionMode.Disabled
.
I tested targeting net8.0-ios
and net9.0-ios
. The stack traces between those two targets were slightly different but neither was impacted by changing the MarshalManagedExceptionMode
.
--> | ||
<Target Name="_SentryMarshalExceptionManagement"> | ||
<PropertyGroup Condition="'$(PublishAot)' == 'true'"> | ||
<MtouchExtraArgs>marshal-managed-exceptions:disable</MtouchExtraArgs> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<MtouchExtraArgs>marshal-managed-exceptions:disable</MtouchExtraArgs> | |
<MtouchExtraArgs>--marshal-managed-exceptions:disable</MtouchExtraArgs> |
I think there's a typo here right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly a typo. It worked either way, In my experience
@jamescrosswell Thanks for testing this.
Did you experience a crash on launch? |
This PR aims to fix #3280, preventing the use of unsupported marshalling behaviour
UnwindNativeCode
for Native AOT by disabling Marshal Exceptions when the code is compiled via native AOT (as advised here).Testing
Testing these changes is more tricky than usual since we did find a way to run this from Unit Tests.
The best way to do this is to: [on a MAC with xcode installed]
sentry-dotnet
repository (make sure you don't do it on a directory that is linked to iCloud)fix/#3680
cd /Samples/Sentry.Samples.Maui
Known error while testing (and their workaround)
error : strip exited with code 13
: this is a known issue with Xcode 16 (now fixed on Xcode16.2 beta) If you get this error, add the following line to the .csproj of the maui project: