Skip to content

Commit 6797ffd

Browse files
committed
Auto merge of #150106 - matthiaskrgr:rollup-98nwcjp, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang/rust#149919 (Correctly encode doc attribute metadata) - rust-lang/rust#150051 (mir_build: Rename `TestCase` to `TestableCase`) - rust-lang/rust#150088 (miri: add `miri_spin_loop` to make `hint::spin_loop` work consistently) - rust-lang/rust#150096 (Revert rust-lang/rust#148937) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c003578 + 0601df2 commit 6797ffd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/shims/foreign_items.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,13 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
435435
// Return value: 0 on success, otherwise the size it would have needed.
436436
this.write_int(if success { 0 } else { needed_size }, dest)?;
437437
}
438+
// Hint that a loop is spinning indefinitely.
439+
"miri_spin_loop" => {
440+
let [] = this.check_shim_sig_lenient(abi, CanonAbi::Rust, link_name, args)?;
441+
442+
// Try to run another thread to maximize the chance of finding actual bugs.
443+
this.yield_active_thread();
444+
}
438445
// Obtains the size of a Miri backtrace. See the README for details.
439446
"miri_backtrace_size" => {
440447
this.handle_miri_backtrace_size(abi, link_name, args, dest)?;

tests/utils/miri_extern.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,7 @@ extern "Rust" {
155155

156156
/// Blocks the current execution if the argument is false
157157
pub fn miri_genmc_assume(condition: bool);
158+
159+
/// Indicate to Miri that this thread is busy-waiting in a spin loop.
160+
pub fn miri_spin_loop();
158161
}

0 commit comments

Comments
 (0)