Skip to content

Commit 43fecf3

Browse files
committed
Add an assert_may_sleep() check on every context switch.
1 parent 92f60f4 commit 43fecf3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libstd/rt/sched.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ impl Scheduler {
540540
// The current task is grabbed from TLS, not taken as an input.
541541
let current_task: ~Task = Local::take::<Task>();
542542

543+
// Check that the task is not in an atomically() section (e.g.,
544+
// holding a pthread mutex, which could deadlock the scheduler).
545+
current_task.death.assert_may_sleep();
546+
543547
// These transmutes do something fishy with a closure.
544548
let f_fake_region = unsafe {
545549
transmute::<&fn(&mut Scheduler, ~Task),

0 commit comments

Comments
 (0)