-
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-unwind" ABI is unsound with "-Cpanic=abort" #83116
Comments
Assigning @rustbot label -I-prioritize +P-medium |
This is probably pretty hard to fix in a way that affects least amount of code negatively. Any function that may at any point, directly or indirectly, end up calling a So AFAICT the only viable fixes here are:
The latter is something LLVM is already capable of inferring by itself, so there's probably little value in doing it in rustc. Maybe later, once or if MIR optimisations start caring about this, I guess? |
There's another possible fix: wrap imported |
We cannot do that, I think. Rust has no idea what the correct personality function would be to "catch" the unwinds from the other side of FFI. Also, isn't the intent that in situations where "C calls Rust calls C" unwinding across POF Rust frames is a supported use-case? |
There is no "correct" or "wrong" personality function to catch unwinds. Any personality function is allowed to catch any non-forced unwind. The |
I don't think this is a support use-case with |
It is allowed to, but we don't necessarily want to expend the effort necessary to implement the personality function in a way that would allow catching e.g. all sorts of different unwinds that arbitrary runtime on the other end could generate. But I guess you're right in that we could just abort inside of the personality function itself.
Okay, I think that's a fair limitation to have. All of the binding crates that rely on "C-unwind" for their functionality would then need to always build with |
Yeah, for now they'd have to tell users "you must build your final binary with |
There's a fair amount of back-and-forth in #86155 between @RalfJung and @alexcrichton about whether or not this issue was resolved there. It looks to me like it was, and we can now close this (though it did not fully resolve the issue of mixed panic modes between crates). Do either of you disagree? |
That sounds accurate to me, the issue here as-is in the OP at least is fixed. |
Is there an issue tracking the mixed panic mode problem? That certainly needs to be tracked somewhere. |
I suppose not. For stabilization I think we're fairly set on just making it
(documented) UB to have an unwind cross a mixed-panic-mode boundary, but it
does seem worth tracking as a potential future improvement.
…On Sat, May 7, 2022, 8:35 AM Ralf Jung ***@***.***> wrote:
Is there an issue tracking the mixed panic mode problem? That certainly
needs to be tracked somewhere.
—
Reply to this email directly, view it on GitHub
<#83116 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARU4TYYM5A252VBAXNOSVLVIZ5URANCNFSM4ZFDHXYA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Oh, I didn't know that. We don't have a lot of "language primitive" UB so we should be careful here. I don't have a strong opinion on this particular one, but I think we should ensure that
Also, isn't this a soundness bug? This can be all in safe code... |
I definitely intend to add it to the undefined behavior section of the reference, as part of the documentation needed for stabilization. And yes, it's a soundness bug, but effectively a very narrow case of an existing soundness bug that is otherwise fixed by the Unfortunately, I have no idea what would be involved in adding support for MIRI to detect this issue. |
Having an issue to track this might be a good start. |
I've opened a new issue here: #96926 |
In the following code,
test
should explicitly be allowed to unwind:However, when building this with
-Cpanic=abort
, we generate LLVM IR as follows:This means unwinding of
test
is UB, i.e., this is a soundness problem.This most likely also affects
#[unwind(allowed)]
, but that attribute is slated for removal anyway.The text was updated successfully, but these errors were encountered: