-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Make rust-intrinsic ABI unwindable #110233
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
Conversation
Stick `#[rustc_nounwind]` to all except `const_eval_select` to undo the change for all other intrinsics.
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
@rustbot label: +A-intrinsics -T-libs |
#[rustc_nounwind] | ||
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; |
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.
Actually the catch_fn
passed to try
could unwind, which will unwind out of the try
intrinsic. However this is a somewhat theoretical concern since our current implementation doesn't call any functions that unwind in the catch callback.
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.
This is an attribute on the signature, which correctly states that we cannot unwind out from the try intrinsic.
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.
If catch_fn
unwinds, then the exception will also unwind out of the try
intrinsic. Only unwinds from try_fn
are caught.
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.
Our codegen assumes try
intrinsic won't unwind. It would be unsound if catch_fn
unwinds.
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.
Tweaked the doc comment to document this, and added a #[rustc_nounwind]
to do_catch
just to be safe.
Sorry, I'm too busy currently to be primary reviewer... @JakobDegen @wesleywiser ? |
tests/mir-opt/issue_104451.rs
Outdated
@@ -0,0 +1,12 @@ | |||
#![feature(core_intrinsics)] |
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.
Can you add a comment describing the purpose of the test, so the intent can be understood without looking up the issue.
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.
And please also describe the topic in two words in the name of the test file. issue_NNNNN.rs
names are a massive anti-pattern
Thanks for fixing the issue! r=me after resolving remaining review comment. @bors delegate=nbdd0121 |
✌️ @nbdd0121 can now approve this pull request |
@bors r=tmiasko |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#109036 (Fix diff option conflict in UI test) - rust-lang#110193 (Check for body owner fallibly in error reporting) - rust-lang#110233 (Make rust-intrinsic ABI unwindable) - rust-lang#110259 (Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented) - rust-lang#110265 (Automatically update the LLVM submodule for musl target (and other places)) - rust-lang#110277 (dead-code-lint: de-dup multiple unused assoc functions) - rust-lang#110283 (Only emit alignment checks if we have a panic_impl) - rust-lang#110291 (Implement `Copy` for `LocationDetail`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Rustup Also add a test for rust-lang/rust#110233
Rustup Also add a test for rust-lang#110233
Rustup Also add a test for rust-lang/rust#110233
Fix #104451, fix rust-lang/miri#2839
r? @RalfJung