Skip to content

Commit 1fe40d4

Browse files
committed
fix(port_std): avoid using parking_lot::Mutex in the UMS structure
Fixes random deadlock in `cargo test time_stress`.
1 parent d652a43 commit 1fe40d4

File tree

1 file changed

+4
-5
lines changed
  • src/constance_port_std/src

1 file changed

+4
-5
lines changed

src/constance_port_std/src/ums.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//! Utterly inefficient cross-platform preemptive user-mode scheduling
22
use once_cell::sync::OnceCell;
3-
use parking_lot::{Mutex, MutexGuard};
43
use std::{
54
panic::{catch_unwind, AssertUnwindSafe},
6-
sync::{mpsc, Arc},
5+
sync::{mpsc, Arc, Mutex, MutexGuard},
76
thread::Result,
87
};
98

@@ -117,7 +116,7 @@ impl<Sched: Scheduler + ?Sized> ThreadGroup<Sched> {
117116
pub fn lock(&self) -> ThreadGroupLockGuard<'_, Sched> {
118117
ThreadGroupLockGuard {
119118
state_ref: &self.state,
120-
guard: self.state.lock(),
119+
guard: self.state.lock().unwrap(),
121120
}
122121
}
123122
}
@@ -270,7 +269,7 @@ pub fn yield_now() {
270269
.expect("current thread does not belong to a thread group");
271270

272271
{
273-
let mut state_guard = thread_group.lock();
272+
let mut state_guard = thread_group.lock().unwrap();
274273
log::trace!("{:?} yielded the processor", state_guard.cur_thread_id);
275274
state_guard.unpark_next_thread();
276275
}
@@ -311,7 +310,7 @@ fn finalize_thread(
311310
log::trace!("{:?} exited with result {:?}", thread_id, result);
312311

313312
// Delete the current thread
314-
let mut state_guard = thread_group.lock();
313+
let mut state_guard = thread_group.lock().unwrap();
315314
state_guard.sched.thread_exited(thread_id);
316315
state_guard.threads.deallocate(thread_id.0).unwrap();
317316
state_guard.num_threads -= 1;

0 commit comments

Comments
 (0)