Handle multiple action records in EH personality function - #160923
Conversation
This comment has been minimized.
This comment has been minimized.
|
Thanks for fixing this! I did the test on my side and it seems to work. and with this PR, I get the correct behavior in my reproducer. |
21dbc6e to
6663fc5
Compare
This comment has been minimized.
This comment has been minimized.
6663fc5 to
c25db43
Compare
|
r? bjorn3 perhaps? |
c25db43 to
689d39d
Compare
| // Note that even for the case of "cleanup" + "filter", decoding them as "catch" is | ||
| // fine: "filter" behaves identically to "catch" except for forced unwind; in case of | ||
| // forced unwind, hitting a "cleanup" landing pad is UB as it indicates that we're | ||
| // unwinding past a non-POF Rust frame. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Wouldn't the unwinder misbehave if you _Unwind_Resume out of a frame that you said is a catch?
There was a problem hiding this comment.
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.
689d39d to
bf56fa4
Compare
|
@bors r+ |
Handle multiple action records in EH personality function LSDA encodes actions are a linked list, we currently only decode the first one. Action records are used for catching specific exception types and for exception specifications, and none of these are present in Rust. However we can still have of multiple of them being present due to LLVM inlining. When this happens, "Catch" is the correct action to execute. We haven't had issues with this because LLVM orders cleanup record last; however GCC doesn't use the same order, so we do need to explicitly handle this case to support both LLVM and GCC codegen. See https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Possible.20bug.20in.20unwind.20function.20in.20std/with/615883393
Handle multiple action records in EH personality function LSDA encodes actions are a linked list, we currently only decode the first one. Action records are used for catching specific exception types and for exception specifications, and none of these are present in Rust. However we can still have of multiple of them being present due to LLVM inlining. When this happens, "Catch" is the correct action to execute. We haven't had issues with this because LLVM orders cleanup record last; however GCC doesn't use the same order, so we do need to explicitly handle this case to support both LLVM and GCC codegen. See https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Possible.20bug.20in.20unwind.20function.20in.20std/with/615883393
…uwer Rollup of 8 pull requests Successful merges: - #137720 (support `#[target_feature(enable = ...)]` on `#[naked]` functions) - #160923 (Handle multiple action records in EH personality function) - #161788 (Check to ensure we're running against the correct LLVM version) - #161644 (bootstrap: Flatten and rename `compute_src_directory_via_git`) - #161702 (Use `drop_guard` in some places in {core,alloc,std}) - #161931 (Revert "Add rustc_test_entrypoint_marker") - #162015 (touch up "get attribute" docs.) - #162019 (remove a couple of redundant clones, thanks clippy)
Handle multiple action records in EH personality function LSDA encodes actions are a linked list, we currently only decode the first one. Action records are used for catching specific exception types and for exception specifications, and none of these are present in Rust. However we can still have of multiple of them being present due to LLVM inlining. When this happens, "Catch" is the correct action to execute. We haven't had issues with this because LLVM orders cleanup record last; however GCC doesn't use the same order, so we do need to explicitly handle this case to support both LLVM and GCC codegen. See https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Possible.20bug.20in.20unwind.20function.20in.20std/with/615883393
Handle multiple action records in EH personality function LSDA encodes actions are a linked list, we currently only decode the first one. Action records are used for catching specific exception types and for exception specifications, and none of these are present in Rust. However we can still have of multiple of them being present due to LLVM inlining. When this happens, "Catch" is the correct action to execute. We haven't had issues with this because LLVM orders cleanup record last; however GCC doesn't use the same order, so we do need to explicitly handle this case to support both LLVM and GCC codegen. See https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Possible.20bug.20in.20unwind.20function.20in.20std/with/615883393
…uwer Rollup of 11 pull requests Successful merges: - #160923 (Handle multiple action records in EH personality function) - #161788 (Check to ensure we're running against the correct LLVM version) - #158303 (Always escape grapheme extenders in `str::escape_debug`) - #161644 (bootstrap: Flatten and rename `compute_src_directory_via_git`) - #161702 (Use `drop_guard` in some places in {core,alloc,std}) - #161713 (Add config for gram editor to .gitignore) - #161792 (Fix and improve diagnostics for lint `rust_2021_prefixes_incompatible_syntax`) - #161931 (Revert "Add rustc_test_entrypoint_marker") - #162015 (touch up "get attribute" docs.) - #162019 (remove a couple of redundant clones, thanks clippy) - #162023 (Remove redundant braces from `NonZero` doctests)
…uwer Rollup of 11 pull requests Successful merges: - #160923 (Handle multiple action records in EH personality function) - #161788 (Check to ensure we're running against the correct LLVM version) - #158303 (Always escape grapheme extenders in `str::escape_debug`) - #161644 (bootstrap: Flatten and rename `compute_src_directory_via_git`) - #161702 (Use `drop_guard` in some places in {core,alloc,std}) - #161713 (Add config for gram editor to .gitignore) - #161792 (Fix and improve diagnostics for lint `rust_2021_prefixes_incompatible_syntax`) - #161931 (Revert "Add rustc_test_entrypoint_marker") - #162015 (touch up "get attribute" docs.) - #162019 (remove a couple of redundant clones, thanks clippy) - #162023 (Remove redundant braces from `NonZero` doctests)
Rollup merge of #160923 - nbdd0121:eh_personality, r=bjorn3 Handle multiple action records in EH personality function LSDA encodes actions are a linked list, we currently only decode the first one. Action records are used for catching specific exception types and for exception specifications, and none of these are present in Rust. However we can still have of multiple of them being present due to LLVM inlining. When this happens, "Catch" is the correct action to execute. We haven't had issues with this because LLVM orders cleanup record last; however GCC doesn't use the same order, so we do need to explicitly handle this case to support both LLVM and GCC codegen. See https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Possible.20bug.20in.20unwind.20function.20in.20std/with/615883393
LSDA encodes actions are a linked list, we currently only decode the first one. Action records are used for catching specific exception types and for exception specifications, and none of these are present in Rust. However we can still have of multiple of them being present due to LLVM inlining. When this happens, "Catch" is the correct action to execute.
We haven't had issues with this because LLVM orders cleanup record last; however GCC doesn't use the same order, so we do need to explicitly handle this case to support both LLVM and GCC codegen.
See https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Possible.20bug.20in.20unwind.20function.20in.20std/with/615883393