Skip to content

Commit 4291aba

Browse files
committed
Add thread-spawn run-pass test
1 parent ab9186c commit 4291aba

9 files changed

+20
-26
lines changed

src/helpers.rs

-16
Original file line numberDiff line numberDiff line change
@@ -628,22 +628,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
628628
}
629629
Ok(())
630630
}
631-
632-
/// Handler that should be called when unsupported functionality is encountered.
633-
/// This function will either panic within the context of the emulated application
634-
/// or return an error in the Miri process context
635-
///
636-
/// Return value of `Ok(bool)` indicates whether execution should continue.
637-
fn handle_unsupported<S: AsRef<str>>(&mut self, error_msg: S) -> InterpResult<'tcx, ()> {
638-
if self.eval_context_ref().machine.panic_on_unsupported {
639-
// message is slightly different here to make automated analysis easier
640-
let error_msg = format!("unsupported Miri functionality: {}", error_msg.as_ref());
641-
self.start_panic(error_msg.as_ref(), StackPopUnwind::Skip)?;
642-
return Ok(());
643-
} else {
644-
throw_unsup_format!("{}", error_msg);
645-
}
646-
}
647631
}
648632

649633
/// Check that the number of args is what we expect.

src/shims/panic.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,20 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
160160
Ok(StackPopJump::Normal)
161161
}
162162
}
163-
163+
164164
/// Handler that should be called when unsupported functionality is encountered.
165165
/// This function will either panic within the context of the emulated application
166166
/// or return an error in the Miri process context
167167
///
168168
/// Return value of `Ok(bool)` indicates whether execution should continue.
169169
fn handle_unsupported<S: AsRef<str>>(&mut self, error_msg: S) -> InterpResult<'tcx, ()> {
170-
let error = format!("unsupported Miri functionality: {}", error_msg.as_ref());
171-
172170
if self.eval_context_ref().machine.panic_on_unsupported {
173171
// message is slightly different here to make automated analysis easier
174-
self.start_panic(error.as_ref(), StackPopUnwind::Skip)?;
172+
let error_msg = format!("unsupported Miri functionality: {}", error_msg.as_ref());
173+
self.start_panic(error_msg.as_ref(), StackPopUnwind::Skip)?;
175174
return Ok(());
176175
} else {
177-
throw_unsup_format!("{}", error);
176+
throw_unsup_format!("{}", error_msg.as_ref());
178177
}
179178
}
180179

src/shims/posix/linux/foreign_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
185185
}
186186
id => {
187187
this.handle_unsupported(format!("can't execute syscall with ID {}", id))?;
188-
return Ok(false);
188+
return Ok(EmulateByNameResult::NotSupported);
189189
}
190190
}
191191
}

src/shims/windows/foreign_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
344344
"CreateThread" => {
345345
this.check_abi(abi, Abi::System { unwind: false })?;
346346

347-
this.handle_unsupported("concurrency is not supported on Windows")?;
348-
return Ok(false);
347+
this.handle_unsupported("Miri does not support concurrency on Windows")?;
348+
return Ok(EmulateByNameResult::AlreadyJumped);
349349
}
350350

351351
// Incomplete shims that we "stub out" just to get pre-main initialization code to work.

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 operation: can't call foreign function: foo
88
}
99
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// compile-flags: -Zmiri-panic-on-unsupported -Zmiri-ignore-leaks
2+
// ignore-linux: Only Windows is not supported.
3+
// ignore-macos: Only Windows is not supported.
4+
5+
use std::thread;
6+
7+
fn main() {
8+
thread::spawn(|| {});
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
thread 'main' panicked at 'unsupported Miri functionality: Miri does not support concurrency on Windows', RUSTLIB/std/src/sys/windows/thread.rs:LL:COL
2+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
thread 'main' panicked at 'unsupported Miri functionality: can't call foreign function "foo"', $DIR/unsupported_foreign_function.rs:9:9
1+
thread 'main' panicked at 'unsupported Miri functionality: can't call foreign function: foo', $DIR/unsupported_foreign_function.rs:9:9
22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

0 commit comments

Comments
 (0)