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

aaudio callbacks are unsound #268

Closed
nicbn opened this issue May 1, 2022 · 1 comment · Fixed by #412
Closed

aaudio callbacks are unsound #268

nicbn opened this issue May 1, 2022 · 1 comment · Fixed by #412

Comments

@nicbn
Copy link

nicbn commented May 1, 2022

https://github.com/rust-windowing/android-ndk-rs/blob/f24606cc840af2f97f0daebe1e2e7cd3aca52287/ndk/src/aaudio.rs#L545-L565

If callback panics and unwinds, ffi_callback unwinds, which is undefined behaviour.

Rust's unwinding strategy is not specified to be fundamentally compatible with any other language's unwinding. As such, unwinding into Rust from another language, or unwinding into another language from Rust is Undefined Behavior. You must absolutely catch any panics at the FFI boundary! What you do at that point is up to you, but something must be done. If you fail to do this, at best, your application will crash and burn. At worst, your application won't crash and burn, and will proceed with completely clobbered state.

@MarijnS95
Copy link
Member

Feel free to submit a PR to address this.

CC @JasperDeSutter.

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 a pull request may close this issue.

2 participants