Skip to content

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

Merged
merged 4 commits into from
Apr 13, 2023
Merged

Make rust-intrinsic ABI unwindable #110233

merged 4 commits into from
Apr 13, 2023

Conversation

nbdd0121
Copy link
Contributor

@nbdd0121 nbdd0121 commented Apr 12, 2023

Stick `#[rustc_nounwind]` to all except `const_eval_select` to undo the
change for all other intrinsics.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 12, 2023
@rustbot
Copy link
Collaborator

rustbot commented Apr 12, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@nbdd0121
Copy link
Contributor Author

@rustbot label: +A-intrinsics -T-libs

@rustbot rustbot added A-intrinsics Area: Intrinsics and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 12, 2023
Comment on lines +2279 to 2282
#[rustc_nounwind]
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@nbdd0121 nbdd0121 Apr 12, 2023

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.

@RalfJung
Copy link
Member

Sorry, I'm too busy currently to be primary reviewer... @JakobDegen @wesleywiser ?

@@ -0,0 +1,12 @@
#![feature(core_intrinsics)]
Copy link
Contributor

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.

Copy link
Contributor

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

@tmiasko
Copy link
Contributor

tmiasko commented Apr 13, 2023

Thanks for fixing the issue! r=me after resolving remaining review comment.

@bors delegate=nbdd0121

@bors
Copy link
Collaborator

bors commented Apr 13, 2023

✌️ @nbdd0121 can now approve this pull request

@nbdd0121
Copy link
Contributor Author

@bors r=tmiasko

@bors
Copy link
Collaborator

bors commented Apr 13, 2023

📌 Commit b07a470 has been approved by tmiasko

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 13, 2023
…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
@bors bors merged commit e85ecbb into rust-lang:master Apr 13, 2023
@rustbot rustbot added this to the 1.70.0 milestone Apr 13, 2023
@nbdd0121 nbdd0121 deleted the intrinsic branch April 13, 2023 23:19
@RalfJung RalfJung mentioned this pull request Apr 14, 2023
bors added a commit to rust-lang/miri that referenced this pull request Apr 14, 2023
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Apr 28, 2023
spikespaz pushed a commit to spikespaz/dotwalk-rs that referenced this pull request Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intrinsics Area: Intrinsics S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Miri reports UB in the core lib Unwinding intrinsics use non-unwinding ABI
7 participants