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

extern C functions need to be C-unwind in Rust 1.81.0 #584

Closed
asomers opened this issue Jun 22, 2024 · 0 comments · Fixed by #585
Closed

extern C functions need to be C-unwind in Rust 1.81.0 #584

asomers opened this issue Jun 22, 2024 · 0 comments · Fixed by #585
Labels
bug Something isn't working

Comments

@asomers
Copy link
Owner

asomers commented Jun 22, 2024

A recent change to rustc (rust-lang/rust#74990) changed the behavior of unwinding from a Rust function across an extern C ABI change. Now, that will cause an abort. This is causing Mockall's CI tests to fail. The possible solutions are either:

  • Require users to specify extern C-unwind instead. This is annoying for users, and it might not be correct for all non-mock functions.
  • Automatically define the mock functions as C-unwind. This is much better. However, it causes two new problems:
    • A function pointer to the original C function will now have a different type from a function pointer to the mock function, because the ABI is part of the function pointer's type.
    • C-unwind does not yet work for variadic functions.
  • Somehow figure out how to make Mockall work with panic=abort. It's not a problem, as long as no tests are should_panic and no tests ever fail 😉 .
@asomers asomers added the bug Something isn't working label Jun 22, 2024
asomers added a commit that referenced this issue Jun 22, 2024
Begining within Rust 1.81
(rust-lang/rust#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 rust-lang/rust#126836 .

Fixes #584
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant