Skip to content

Commit c3d235d

Browse files
committed
Update README, add tests
1 parent 1ec8b64 commit c3d235d

File tree

8 files changed

+23
-7
lines changed

8 files changed

+23
-7
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ environment variable:
262262
this pointer. Note that it is not currently guaranteed that code that works
263263
with `-Zmiri-track-raw-pointers` also works without
264264
`-Zmiri-track-raw-pointers`, but for the vast majority of code, this will be the case.
265+
* `-Zmiri-panic-on-unsupported` will makes some forms of unsupported functionality
266+
such as FFI and unsupported syscalls panic within the context of the emulated
267+
application instead of raising an error within the context of Miri.
265268

266269
Some native rustc `-Z` flags are also very relevant for Miri:
267270

src/bin/miri.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn main() {
233233
"-Zmiri-ignore-leaks" => {
234234
miri_config.ignore_leaks = true;
235235
}
236-
"-Zmiri-panic-on-unsupported-syscalls" => {
236+
"-Zmiri-panic-on-unsupported" => {
237237
miri_config.panic_on_unsupported = true;
238238
}
239239
"-Zmiri-track-raw-pointers" => {

src/shims/posix/linux/foreign_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
189189
);
190190
if this.eval_context_ref().machine.panic_on_unsupported {
191191
// message is slightly different here to make automated analysis easier
192-
this.start_panic(error_msg.as_ref(), StackPopUnwind::NotAllowed)?;
192+
this.start_panic(error_msg.as_ref(), StackPopUnwind::Skip)?;
193193
return Ok(false);
194194
} else {
195195
throw_unsup_format!("{}", error_msg);
@@ -233,7 +233,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
233233
);
234234
if this.eval_context_ref().machine.panic_on_unsupported {
235235
// message is slightly different here to make automated analysis easier
236-
this.start_panic(error_msg.as_ref(), StackPopUnwind::NotAllowed)?;
236+
this.start_panic(error_msg.as_ref(), StackPopUnwind::Skip)?;
237237
return Ok(false);
238238
} else {
239239
throw_unsup_format!("{}", error_msg);

src/shims/posix/macos/foreign_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
163163
);
164164
if this.eval_context_ref().machine.panic_on_unsupported {
165165
// message is slightly different here to make automated analysis easier
166-
this.start_panic(error_msg.as_ref(), StackPopUnwind::NotAllowed)?;
166+
this.start_panic(error_msg.as_ref(), StackPopUnwind::Skip)?;
167167
return Ok(false);
168168
} else {
169169
throw_unsup_format!("{}", error_msg);

src/shims/windows/foreign_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
346346
let error_msg =
347347
"unsupported Miri functionality: concurrency is not supported on Windows";
348348
if this.eval_context_ref().machine.panic_on_unsupported {
349-
this.start_panic(error_msg, StackPopUnwind::NotAllowed)?;
349+
this.start_panic(error_msg, StackPopUnwind::Skip)?;
350350
return Ok(false);
351351
} else {
352352
throw_unsup_format!("{}", error_msg);
@@ -430,7 +430,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
430430
);
431431
if this.eval_context_ref().machine.panic_on_unsupported {
432432
// message is slightly different here to make automated analysis easier
433-
this.start_panic(error_msg.as_ref(), StackPopUnwind::NotAllowed)?;
433+
this.start_panic(error_msg.as_ref(), StackPopUnwind::Skip)?;
434434
return Ok(false);
435435
} else {
436436
throw_unsup_format!("{}", error_msg);

tests/compile-fail/unsupported_foreign_function.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ fn main() {
44
}
55

66
unsafe {
7-
foo(); //~ ERROR unsupported operation: can't call foreign function: foo
7+
foo(); //~ ERROR unsupported Miri functionality: can't call foreign function "foo"
88
}
99
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// compile-flags: -Zmiri-panic-on-unsupported
2+
3+
fn main() {
4+
extern "Rust" {
5+
fn foo();
6+
}
7+
8+
unsafe {
9+
foo();
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
thread 'main' panicked at 'unsupported Miri functionality: can't call foreign function "foo"', $DIR/unsupported_foreign_function.rs:9:9
2+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

0 commit comments

Comments
 (0)