-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #101168) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -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); |
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.
What is the difference between cleanup and filter? How should a backend implement it?
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.
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.
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 corresponds to section 7.5 "Exception Specification" of that document?
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.
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.
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 Examples of
|
r? @Amanieu |
994b4a4
to
8e349db
Compare
@@ -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) |
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 seems incorrect?
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.
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?
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.
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
.
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.
These are part of generic/gimple: https://godbolt.org/z/5adjbahnd
r=me after double-checking the GCC changes with @antoyo. |
@bors r+ |
📌 Commit 368cf88fbedf18ef2789acabbe80747c9529a555 has been approved by It is now in the queue for this repository. |
⌛ Testing commit 368cf88fbedf18ef2789acabbe80747c9529a555 with merge 5a90fe78cc076aca81d61b2c0f06c7e666aef04c... |
💔 Test failed - checks-actions |
@@ -0,0 +1,17 @@ | |||
// Tests that forced unwind through POF Rust frames wouldn't trigger our terminating guards. |
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.
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.
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.
@bors r+ |
📌 Commit 5516791017a61acc9e5b1964accc8775bc340abe has been approved by It is now in the queue for this repository. |
⌛ Testing commit 5516791017a61acc9e5b1964accc8775bc340abe with merge 08c382f09932d3d0b04871bb834f68d59ffc8bb3... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
Somehow a commit from my other (already merged) PR was mixed in. Fixed |
@bors r+ |
…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
Fix #101469