-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Handle multiple action records in EH personality function #160923
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| //@ run-pass | ||
| //@ needs-unwind | ||
| //@ ignore-backends: gcc | ||
| //@ compile-flags: -Copt-level=3 | ||
|
|
||
| struct Guard; | ||
|
|
||
| impl Drop for Guard { | ||
| fn drop(&mut self) { | ||
| core::hint::black_box(()); | ||
| } | ||
| } | ||
|
|
||
| #[inline(never)] | ||
| fn unwind() { | ||
| if core::hint::black_box(true) { | ||
| std::panic::resume_unwind(Box::new(())); | ||
| } | ||
| } | ||
|
|
||
| fn main() { | ||
| // The `catch_unwind` will generate `landingpad catch` and the destructor will generate | ||
| // `landingpad cleanup`; after LLVM inlining it will become `landingpad cleanup catch`, and this | ||
| // is translated to action record chains in LSDA. | ||
| let _ = std::panic::catch_unwind(|| { | ||
| let _guard = Guard; | ||
| unwind(); | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 if there are two cleanup actions for whatever reason? Should this explicitly check that at least one action is a filter or catch if there are multiple ones and abort otherwise?
View changes since the review
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.
That'll be a compiler bug? I don't think we should defend against something that won't happen at a cost of code size.
Also, nothing will be catastrophically wrong even if we catch a cleanup frame, we will just be skipping phase 1 of unwind and perform phase 2 unwind for further stack frames, similar to 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.
Wouldn't the unwinder misbehave if you
_Unwind_Resumeout of a frame that you said is a catch?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 might unwind more frames, but nothing will be terribly wrong. Anyhow, neither GCC nor LLVM will emit duplicate action record entry, so I don't think this is worth handling.