diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 28f9486a67793..85d1ee3da94cc 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -1473,9 +1473,13 @@ extern mod rustrt { fn rust_task_is_unwinding(task: *rust_task) -> bool; fn rust_osmain_sched_id() -> sched_id; + #[rust_stack] fn rust_task_inhibit_kill(t: *rust_task); + #[rust_stack] fn rust_task_allow_kill(t: *rust_task); + #[rust_stack] fn rust_task_inhibit_yield(t: *rust_task); + #[rust_stack] fn rust_task_allow_yield(t: *rust_task); fn rust_task_kill_other(task: *rust_task); fn rust_task_kill_all(task: *rust_task); diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 061e87ebff82d..791c6a6551f97 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -631,27 +631,29 @@ rust_task::on_rust_stack() { } } +// NB: In inhibit_kill and allow_kill, helgrind would complain that we need to +// hold lifecycle_lock while accessing disallow_kill. Even though another +// killing task may access disallow_kill concurrently, this is not racy +// because the killer only cares if this task is blocking, and block() already +// uses proper locking. See https://github.com/mozilla/rust/issues/3213 . + void rust_task::inhibit_kill() { - scoped_lock with(lifecycle_lock); // Here might be good, though not mandatory, to check if we have to die. disallow_kill++; } void rust_task::allow_kill() { - scoped_lock with(lifecycle_lock); assert(disallow_kill > 0 && "Illegal allow_kill(): already killable!"); disallow_kill--; } void rust_task::inhibit_yield() { - scoped_lock with(lifecycle_lock); disallow_yield++; } void rust_task::allow_yield() { - scoped_lock with(lifecycle_lock); assert(disallow_yield > 0 && "Illegal allow_yield(): already yieldable!"); disallow_yield--; }