Skip to content

Commit

Permalink
Add an assert_may_sleep() check on every context switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
bblum committed Aug 2, 2013
1 parent 92f60f4 commit 43fecf3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libstd/rt/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ impl Scheduler {
// The current task is grabbed from TLS, not taken as an input.
let current_task: ~Task = Local::take::<Task>();

// Check that the task is not in an atomically() section (e.g.,
// holding a pthread mutex, which could deadlock the scheduler).
current_task.death.assert_may_sleep();

// These transmutes do something fishy with a closure.
let f_fake_region = unsafe {
transmute::<&fn(&mut Scheduler, ~Task),
Expand Down

1 comment on commit 43fecf3

@brson
Copy link

@brson brson commented on 43fecf3 Aug 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ p=2 really nice. thanks. :bowtie:

Please sign in to comment.