-
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 foreign Rust exceptions from being caught #102721
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
@@ -47,7 +47,12 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo { | |||
name: b"rust_panic\0".as_ptr(), |
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.
Maybe change this to avoid unsoundness in combination with older rust versions? Same for the exception type for the other unwinding mechanisms.
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.
I think it's worth mentioning that catching a foreign unwind in Rust is UB. We are providing guards against this but it's not part of guarantee.
Currently there are no ways to hit this on stable, and if you hit this using nightly you are already in UB territory. So we can change this string (and the exception class), but we don't have to.
r? @Amanieu |
@bors r+ |
Prevent foreign Rust exceptions from being caught Fix rust-lang#102715 Use the address of a static variable (which is guaranteed to be unique per copy of std) to tell apart if a Rust exception comes from local or foreign Rust code, and abort for the latter.
I hope I am correct in doing this, but this should probably not be merged with the unsoundness above (I think that also caused the rollup to fail). @bors r- |
@joboet: 🔑 Insufficient privileges: Not in reviewers |
Nice catch! @bors r+ |
📌 Commit 65c7d94d94e575edc934de5081d674856baf67df has been approved by It is now in the queue for this repository. |
⌛ Testing commit 65c7d94d94e575edc934de5081d674856baf67df with merge d3129761e1defe2e2c5878b84934fa9664e251a7... |
💔 Test failed - checks-actions |
Hmm, I tested the test case on nightly i686-pc-windows-gnu and it doesn't work either. I am not familiar enough with windows-gnu targets to troubleshoot it, unfortunately. However, given that the problem is not related to the main PR itself, I'll just mark the test as |
i686-mingw requires unwind tables to be registered with the unwinder when the module is loaded. We do this, but the problem in this case is that the cdylib has its own copy of libgcc statically linked into it. This is somewhat by design so that mingw executables don't have a runtime dependency on libgcc_s.dll, but it breaks cross-DLL unwinding since the respective unwinders are not aware of the unwind tables in other modules. I think ignoring the test is fine in this case, but only on i686. Other architectures do not have this limitation. |
Yeah, I tested this on x86_64 MinGW and it works fine. However we only have |
You can pass a full target triple: |
@bors r+ |
Prevent foreign Rust exceptions from being caught Fix rust-lang#102715 Use the address of a static variable (which is guaranteed to be unique per copy of std) to tell apart if a Rust exception comes from local or foreign Rust code, and abort for the latter.
Prevent foreign Rust exceptions from being caught Fix rust-lang#102715 Use the address of a static variable (which is guaranteed to be unique per copy of std) to tell apart if a Rust exception comes from local or foreign Rust code, and abort for the latter.
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#102634 (compiletest: Refactor test rustcflags) - rust-lang#102721 (Prevent foreign Rust exceptions from being caught) - rust-lang#103415 (filter candidates in pick probe for diagnostics) - rust-lang#103618 (Rename some `OwnerId` fields.) - rust-lang#103625 (Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions) - rust-lang#103653 (Add missing impl blocks for item reexported from private mod in JSON output) - rust-lang#103699 (Emit proper error when casting to `dyn*`) - rust-lang#103719 (fix typo in `try_reserve` method from `HashMap` and `HashSet`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Prevent foreign Rust exceptions from being caught Fix rust-lang#102715 Use the address of a static variable (which is guaranteed to be unique per copy of std) to tell apart if a Rust exception comes from local or foreign Rust code, and abort for the latter.
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#102634 (compiletest: Refactor test rustcflags) - rust-lang#102721 (Prevent foreign Rust exceptions from being caught) - rust-lang#103415 (filter candidates in pick probe for diagnostics) - rust-lang#103618 (Rename some `OwnerId` fields.) - rust-lang#103625 (Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions) - rust-lang#103653 (Add missing impl blocks for item reexported from private mod in JSON output) - rust-lang#103699 (Emit proper error when casting to `dyn*`) - rust-lang#103719 (fix typo in `try_reserve` method from `HashMap` and `HashSet`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fix #102715
Use the address of a static variable (which is guaranteed to be unique per copy of std) to tell apart if a Rust exception comes from local or foreign Rust code, and abort for the latter.