ash-rs / ash

Vulkan bindings for Rust
Apache License 2.0
1.81k stars 187 forks source link

It is UB to unwind over the FFI barrier #578

Open cheako opened 2 years ago

cheako commented 2 years ago

https://github.com/MaikKlein/ash/blob/b7aff3b432d853528a47bf99fa3e7f0d841c4112/ash/src/vk/features.rs#L87

These should be eprintln! followed by process::exit.

MaikKlein commented 2 years ago

This is only called from within Rust so never crosses the FFI barrier and is caught by the rust runtime. But I am not sure if this is already UB because it is inside an extern block 🤔 .

Ralith commented 2 years ago

It's not clear to me whether this counts. https://doc.rust-lang.org/nomicon/ffi.html just says "across an FFI boundary." https://doc.rust-lang.org/reference/items/external-blocks.html does not mention panics/unwinding at all AFAICT. https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html#changes-to-the-behavior-of-existing-abi-strings says:

Prior to this RFC, any unwinding operation that crossed an extern "C" boundary, either from a panic! "escaping" from a Rust function defined with extern "C" or by entering Rust from another language via an entrypoint declared with extern "C", caused undefined behavior.

but it's not clear to me if that's normative.