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

Fix exception-safety in callbacks from Rust to C++ #4463

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Sep 10, 2024

We've been using cxx slightly wrong around callbacks from Rust to C++. This isn't likely a problem as we only have two such callbacks and they call into the C++ logging system which rarely if ever throws, but just to be on the safe side we should define these functions as returning cxx::Result not a plain Rust type. It turns out cxx puts a noexcept wrapper around all such callbacks to ensure they don't throw (and confuse Rust ABIs) and by doing this it means any throw in the C++ side would wind up causing the C++ runtime to call std::terminate (which is what it does when a noexcept function throws anyways).

The fix is very straightforward.

@anupsdf anupsdf added this pull request to the merge queue Sep 10, 2024
Merged via the queue into stellar:master with commit 64da5e9 Sep 10, 2024
14 checks passed
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