asomers / mockall

A powerful mock object library for Rust
Apache License 2.0
1.5k stars 62 forks source link

Use the C-unwind ABI instead of C when mocking extern C functions #585

Closed asomers closed 3 months ago

asomers commented 3 months ago

Begining within Rust 1.81 (https://github.com/rust-lang/rust/issues/74990) Rust will abort when attempting to unwind a panic across an "extern C" boundary. Previously it was technically UB, but it worked and Mockall relied on it. Now, unwinding across such a boundary requires the "extern C-unwind" ABI. Use that ABI in the generated code.

However, don't use that ABI when mocking a C variadic function. That doesn't work, due to https://github.com/rust-lang/rust/issues/126836 .

Fixes #584

asomers commented 3 months ago

@Enes1313 since you are the one who first requested the extern "C" linkage, could you please test your project with this PR branch?

asomers commented 3 months ago

@Enes1313 I'm going to go ahead and merge this since CI on the master branch is broken . But I'd still appreciate any post-merge feedback you can provide.