Skip to content

Strange issue with XCode 14, native library & C++ exceptions #16546

@projectgoav

Description

@projectgoav

When running our app that's linked to a native C++ library, any exception thrown by that library causes the application to terminate with libstdc++:abi terminated due to uncaught exception <library type> when deployed to device.

This particular library is developed by us, has not been changed for many months and makes use of exceptions for control flow.

Issue first started to occur with the upgrade to XCode 14. It only happens when deploying to physical devices (iOS 12 -> 16). Simulators are not effected.

Everything below was tested on Visual Studio Mac 2022 v17.3.8 (Build 5) (Run on both an Intel and M1 powered Mac)

XCode 13.4.1 / Xamarin iOS 15.10.0.5 => Application runs as expected
XCode 14.0.1 / Xamarin iOS 15.10.0.5 => Application crashes due to uncaught exception
XCode 14.0.1 / Xamarin iOS 16.0.0.72 => Application crashes due to uncaught exception
XCode 14.1.0 / Xamarin iOS 16.0.0.72 => Application crashes due to uncaught exception

The following occurs when our library was built with XCode 9 & XCode 14.

If our library is built in DEBUG mode (-g -O0) the problem does not occur
If our library is built in RELEASE mode with either -O0 or -O1, the problem does not occur
If our library is built in RELEASE mode with either -O2 or -O3 the problem occurs.

When the problem occurs, and based on my rudimentary understanding, it's almost as when the exception is thrown, it fails to unwind the stack to the appropriate catch block and ends up treating it as unhandled.

Are you aware of anything that has changed with the introduction to XCode 14 and linking native code to Xamarin.iOS applications?

As our project it quite large, I am in the process of trying to obtain a small reprodicable example. If it is to do with how optmisations are applied, I might not be able to achieve that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fixregressionThe issue or pull request is a regression

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions