-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #102721 - nbdd0121:panic, r=Amanieu
Prevent foreign Rust exceptions from being caught 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.
- Loading branch information
Showing
6 changed files
with
101 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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
11 changes: 11 additions & 0 deletions
11
src/test/run-make-fulldeps/foreign-rust-exceptions/Makefile
This file contains 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,11 @@ | ||
# ignore-i686-pc-windows-gnu | ||
|
||
# This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder | ||
# so cross-DLL unwinding does not work. | ||
|
||
include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) bar.rs --crate-type=cdylib | ||
$(RUSTC) foo.rs | ||
$(call RUN,foo) 2>&1 | $(CGREP) "Rust cannot catch foreign exceptions" |
This file contains 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,7 @@ | ||
#![crate_type = "cdylib"] | ||
#![feature(c_unwind)] | ||
|
||
#[no_mangle] | ||
extern "C-unwind" fn panic() { | ||
panic!(); | ||
} |
This file contains 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,13 @@ | ||
#![feature(c_unwind)] | ||
|
||
#[cfg_attr(not(windows), link(name = "bar"))] | ||
#[cfg_attr(windows, link(name = "bar.dll"))] | ||
extern "C-unwind" { | ||
fn panic(); | ||
} | ||
|
||
fn main() { | ||
let _ = std::panic::catch_unwind(|| { | ||
unsafe { panic() }; | ||
}); | ||
} |