Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions crates/vm/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,6 @@ mod mt {
EVAL_BREAKER.fetch_and(!STOP_BIT, Ordering::Release);
}

#[cfg(test)]
pub(crate) fn stop_bit_set() -> bool {
EVAL_BREAKER.load(Ordering::Relaxed) & STOP_BIT != 0
}

/// Record that finalization has begun. See `FINALIZING_BIT`.
pub(crate) fn set_finalizing_bit() {
EVAL_BREAKER.fetch_or(FINALIZING_BIT, Ordering::Release);
Expand All @@ -203,8 +198,6 @@ mod mt {
}
}

#[cfg(all(test, feature = "threading"))]
pub(crate) use mt::stop_bit_set;
#[cfg(feature = "threading")]
pub(crate) use mt::{
clear_qsbr_bit, clear_stop_bit, qsbr_bit_set, schedule_gc, set_finalizing_bit, set_qsbr_bit,
Expand Down
26 changes: 5 additions & 21 deletions crates/vm/src/vm/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1851,36 +1851,20 @@ for _ in range(40):
worker.join().expect("worker panicked");
}

/// Per-thread `stop_requested` must trip the eval breaker even when the
/// process-wide `STOP_BIT` is clear.
/// Per-thread `stop_requested` must trip the eval breaker on its own.
/// Do not touch or assert the process-wide eval-breaker word: other tests
/// in this process may be flickering `STOP_BIT` at the same time.
#[cfg(feature = "threading")]
#[test]
fn eval_breaker_tripped_when_stop_requested_and_stop_bit_clear() {
fn eval_breaker_tripped_when_stop_requested() {
let interp = Interpreter::without_stdlib(Default::default());
interp.enter(|vm| {
assert!(
crate::vm::thread::set_stop_requested_for_current_thread(true),
"current thread has no stop_requested flag"
);
// STOP_BIT is process-wide; a parallel stop-the-world test can
// set it between the clear and the load. Retry until this thread
// observes it clear, then sample `eval_breaker_tripped`.
let (stop_bit, tripped) = {
let mut stop_bit = true;
let mut tripped = false;
for _ in 0..10_000 {
crate::signal::clear_stop_bit();
stop_bit = crate::signal::stop_bit_set();
tripped = vm.eval_breaker_tripped();
if !stop_bit {
break;
}
std::thread::yield_now();
}
(stop_bit, tripped)
};
let tripped = vm.eval_breaker_tripped();
crate::vm::thread::set_stop_requested_for_current_thread(false);
assert!(!stop_bit, "process-wide STOP_BIT was set");
assert!(tripped);
});
}
Expand Down
Loading