]> git.lizzy.rs Git - rust.git/commitdiff
Add an assert_may_sleep() check on every context switch.
authorBen Blum <bblum@andrew.cmu.edu>
Fri, 2 Aug 2013 21:23:00 +0000 (17:23 -0400)
committerBen Blum <bblum@andrew.cmu.edu>
Fri, 2 Aug 2013 21:31:45 +0000 (17:31 -0400)
src/libstd/rt/sched.rs

index 36b9812522979df01eb44fcefa9174acad0b2a38..dfe003253c2cf2e6cd656f2da62011108a9da140 100644 (file)
@@ -540,6 +540,10 @@ pub fn change_task_context(~self,
         // 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),