-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
C-variadic functions may not be extern "C-unwind" #126836
Comments
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
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
Thanks for reporting this. It seems in several places, we just check for the literal |
Just for note: You were not supposed to be allowing panics to unwind into C. Unless I am misunderstanding something, if this is a regression for you in functionality, your code was UB. I don't mean to quibble much, though, as I literally already fixed this. |
Yeah, I realize that now. But since it worked before, I never bothered to read any of the fine details about external C functions. And thanks for the amazingly fast PR! |
Rollup merge of rust-lang#126843 - workingjubilee:allow-variadics-in-c-unwind, r=nnethercote Allow "C-unwind" fn to have C variadics Fixes rust-lang#126836
Now that rust-lang/rust#126836 is fixed.
Overview
Using the unstable c_variadic feature, functions may be variadic as long as they have an
extern "C"
ABI. That used to be a reasonable restriction. However, after #74990 ,extern "C"
isn't as useful as it used to be. Now, any function that might panic needs to beextern "C-unwind"
. This may not technically be a compiler regression. But it's certainly a regression in functionality. Previously, Mockall was able to mock C variadic functions. Now, it cannot. Would it be possible to relax that restriction?Example
I tried this code:
I expected to see this happen: It should compile ok.
Instead, this happened: It fails with this error:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: