Skip to content
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

Prevent aborting guard from aborting the process in a forced unwind #104070

Merged
merged 7 commits into from
May 8, 2023

Conversation

nbdd0121
Copy link
Contributor

@nbdd0121 nbdd0121 commented Nov 6, 2022

Fix #101469

@rustbot
Copy link
Collaborator

rustbot commented Nov 6, 2022

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@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 Nov 6, 2022
@bors
Copy link
Contributor

bors commented Nov 15, 2022

☔ The latest upstream changes (presumably #101168) made this pull request unmergeable. Please resolve the merge conflicts.

@jackh726 jackh726 added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 10, 2023
@@ -272,6 +272,7 @@ pub trait BuilderMethods<'a, 'tcx>:

// These are used by everyone except msvc
fn cleanup_landing_pad(&mut self, pers_fn: Self::Value) -> (Self::Value, Self::Value);
fn filter_landing_pad(&mut self, pers_fn: Self::Value) -> (Self::Value, Self::Value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between cleanup and filter? How should a backend implement it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's purely metadata in LSDA. https://itanium-cxx-abi.github.io/cxx-abi/exceptions.pdf

A negative value in action record means filter, a positive value means catch, and zero (or absence of action record) means cleanup.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This corresponds to section 7.5 "Exception Specification" of that document?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I call it filter because that's how LLVM calls it.

The code here doesn't actually specify any exceptions (corresponds to C++ throw()), so it's essentially catch-all. But it provides a way for the personality function to distinguish terminate vs cleanup.

@nbdd0121 nbdd0121 marked this pull request as ready for review April 7, 2023 15:31
@rustbot
Copy link
Collaborator

rustbot commented Apr 7, 2023

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

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

nbdd0121 commented Apr 7, 2023

r? @Amanieu

@rustbot rustbot assigned Amanieu and unassigned wesleywiser Apr 7, 2023
@nbdd0121 nbdd0121 force-pushed the unwind branch 2 times, most recently from 994b4a4 to 8e349db Compare April 7, 2023 16:16
@@ -1226,6 +1226,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
(value1, value2)
}

fn filter_landing_pad(&mut self, pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
self.cleanup_landing_pad(pers_fn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proper way to encode this in GCC would be <<<eh_filter (NULL)>>> (or even better, <<<eh_must_not_throw (terminate)>>>, which is something we hoped for for LLVM!). But I don't think there is support in libgccjit yet, @antoyo to confirm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll take care of this. I'm not done with supporting unwinding yet.

But, please add a // TODO(antoyo): generate the correct landing pad.

For my personal information, what are <<<eh_filter (NULL)>>> and <<<eh_must_not_throw (terminate)>>>? I've never seen this syntax. Are they C attributes?

I don't remember exactly what filter is doing, but the proper implementation of this method might be very similar as cleanup_landing_pad, but without adding to self.cleanup_blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are part of generic/gimple: https://godbolt.org/z/5adjbahnd

compiler/rustc_codegen_llvm/src/builder.rs Outdated Show resolved Hide resolved
@Amanieu
Copy link
Member

Amanieu commented Apr 7, 2023

r=me after double-checking the GCC changes with @antoyo.

@Amanieu
Copy link
Member

Amanieu commented Apr 8, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Apr 8, 2023

📌 Commit 368cf88fbedf18ef2789acabbe80747c9529a555 has been approved by Amanieu

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-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Apr 8, 2023
@bors
Copy link
Contributor

bors commented Apr 8, 2023

⌛ Testing commit 368cf88fbedf18ef2789acabbe80747c9529a555 with merge 5a90fe78cc076aca81d61b2c0f06c7e666aef04c...

@bors
Copy link
Contributor

bors commented Apr 8, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 8, 2023
@@ -0,0 +1,17 @@
// Tests that forced unwind through POF Rust frames wouldn't trigger our terminating guards.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a Windows version of this test that uses longjmp. On Windows longjmp is implemented using SEH exceptions and effectively acts like a forced unwind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a test longjmp-across-rust added by #48572 to fix #48251

@Amanieu
Copy link
Member

Amanieu commented May 7, 2023

@bors r+

@bors
Copy link
Contributor

bors commented May 7, 2023

📌 Commit 5516791017a61acc9e5b1964accc8775bc340abe has been approved by Amanieu

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 May 7, 2023
@bors
Copy link
Contributor

bors commented May 8, 2023

⌛ Testing commit 5516791017a61acc9e5b1964accc8775bc340abe with merge 08c382f09932d3d0b04871bb834f68d59ffc8bb3...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 8, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 8, 2023
@nbdd0121
Copy link
Contributor Author

nbdd0121 commented May 8, 2023

Somehow a commit from my other (already merged) PR was mixed in. Fixed

@Amanieu
Copy link
Member

Amanieu commented May 8, 2023

@bors r+

@bors
Copy link
Contributor

bors commented May 8, 2023

📌 Commit 16abe6c has been approved by Amanieu

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 May 8, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2023
…mpiler-errors

Rollup of 6 pull requests

Successful merges:

 - rust-lang#104070 (Prevent aborting guard from aborting the process in a forced unwind)
 - rust-lang#109410 (Introduce `AliasKind::Inherent` for inherent associated types)
 - rust-lang#111004 (Migrate `mir_transform` to translatable diagnostics)
 - rust-lang#111118 (Suggest struct when we get colon in fileds in enum)
 - rust-lang#111170 (Diagnostic args are still args if they're documented)
 - rust-lang#111354 (Fix miscompilation when calling default methods on `Future`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fcb275f into rust-lang:master May 8, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pthread_exit no longer works in panic=abort
10 participants