Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7aff711

Browse files
committed
Check if the thread is blocked before waking them up
1 parent 8f178e4 commit 7aff711

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/tools/miri/src/concurrency/thread.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ impl<'tcx> ThreadManager<'tcx> {
578578
self.threads[thread_id].state.is_terminated()
579579
}
580580

581+
fn has_blocked_on_epoll(&self, thread_id: ThreadId) -> bool {
582+
self.threads[thread_id].state.is_blocked_on(BlockReason::Epoll)
583+
}
584+
581585
/// Have all threads terminated?
582586
fn have_all_terminated(&self) -> bool {
583587
self.threads.iter().all(|thread| thread.state.is_terminated())
@@ -1137,6 +1141,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
11371141
this.machine.threads.enable_thread(thread_id);
11381142
}
11391143

1144+
#[inline]
1145+
fn has_blocked_on_epoll(&self, thread_id: ThreadId) -> bool {
1146+
let this = self.eval_context_ref();
1147+
this.machine.threads.has_blocked_on_epoll(thread_id)
1148+
}
1149+
11401150
#[inline]
11411151
fn active_thread_stack<'a>(&'a self) -> &'a [Frame<'tcx, Provenance, FrameExtra<'tcx>>] {
11421152
let this = self.eval_context_ref();

src/tools/miri/src/shims/unix/linux/epoll.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
600600
waiter.sort();
601601
waiter.dedup();
602602
for thread_id in waiter {
603-
this.unblock_thread(thread_id, BlockReason::Epoll)?;
603+
if this.has_blocked_on_epoll(thread_id) {
604+
this.unblock_thread(thread_id, BlockReason::Epoll)?;
605+
}
604606
}
605607
Ok(())
606608
}

0 commit comments

Comments
 (0)