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

C API throws C++ exceptions #1471

Open
WilliamVenner opened this issue Oct 25, 2024 · 1 comment
Open

C API throws C++ exceptions #1471

WilliamVenner opened this issue Oct 25, 2024 · 1 comment

Comments

@WilliamVenner
Copy link

The C API should not throw C++ exceptions: languages that use the C ABI will likely not have any machinery for properly handling C++ stack unwinds when a C++ exception occurs across an FFI boundary.

For example, the C API crashes Rust programs when a C++ exception occurs:

fatal runtime error: Rust cannot catch foreign exceptions

This makes debugging particularly difficult.

A solution that doesn't require breaking changes would be wrapping all C++ function calls from a C API function (or the entirety of the C API function itself) in a try { ... } catch { ... } and handle any C++ exceptions by printing debugging information, then aborting.

@csukuangfj
Copy link
Collaborator

Could you describe which API throws a C++ exception?

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

No branches or pull requests

2 participants