-
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
Fix coroutine validation for mixed panic strategy #118422
Conversation
Validation introduced in rust-lang#113124 allows UnwindAction::Continue and TerminatorKind::Resume to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates. Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies. Avoid the problem by executing AbortUnwindingCalls along with the validation.
(rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
pm::run_passes( | ||
tcx, | ||
&mut body, | ||
&[], | ||
&[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that generator drop shims will inherit the panic strategy of the crate that they're being monomorphized in, rather than the crate that they're coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
One could also try to move everything in other direction. That is, move validation from shim building to state transform, but unfortunately this introduces query cycle at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. Do you know whether other shims default to definition-crate or mono-crate for their panic strategy? This inconsistency seems important to iron out, I feel? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To place this into context. While the mixed builds are allowed, the final strategy in that case is abort. The motivating use case being the standard library pre-built with unwind strategy, where the end user selects between unwind and abort.
The other shims, like the one here, are constructed using the strategy of the crate that requests the MIR. Usually, MIR would be requested at the monomorphization time, but it is an implementation detail, given that optimization like MIR inlining can request it earlier.
Any differences here should be at best quality of implementation kind.
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#116839 (Implement thread parking for xous) - rust-lang#118265 (remove the memcpy-on-equal-ptrs assumption) - rust-lang#118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`) - rust-lang#118394 (Remove HIR opkinds) - rust-lang#118398 (Add proper cfgs in std) - rust-lang#118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context) - rust-lang#118422 (Fix coroutine validation for mixed panic strategy) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#116839 (Implement thread parking for xous) - rust-lang#118265 (remove the memcpy-on-equal-ptrs assumption) - rust-lang#118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`) - rust-lang#118394 (Remove HIR opkinds) - rust-lang#118398 (Add proper cfgs in std) - rust-lang#118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context) - rust-lang#118422 (Fix coroutine validation for mixed panic strategy) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#118422 - tmiasko:mix, r=compiler-errors Fix coroutine validation for mixed panic strategy Validation introduced in rust-lang#113124 allows `UnwindAction::Continue` and `TerminatorKind::Resume` to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates. Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies. Avoid the problem by executing `AbortUnwindingCalls` along with the validation. Fixes rust-lang#116953.
Going to nominate for stable backport since this fixes a (supposedly) @rustbot label +stable-nominated |
Stable backport declined as per compiler team on Zulip (the impact of code compiled with A beta backport was also suggested and seemed to receive more consensus. @rustbot label -stable-nominated +beta-accepted |
[beta] backports - Build pre-coroutine-transform coroutine body rust-lang#117686 - Fix coroutine validation for mixed panic strategy rust-lang#118422 - ConstProp: Remove const when rvalue check fails. rust-lang#118426 - Dispose llvm::TargetMachines prior to llvm::Context being disposed rust-lang#118464 r? ghost
Validation introduced in #113124 allows
UnwindAction::Continue
andTerminatorKind::Resume
to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates.Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies.
Avoid the problem by executing
AbortUnwindingCalls
along with the validation.Fixes #116953.