about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 952e5c8c47d..92637ace632 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -155,9 +155,12 @@ cleanup_task(cleanup_args *args) {
 
     task->die();
 
-    if (task->killed && !threw_exception) {
-        LOG(task, task, "Task killed during termination");
-        threw_exception = true;
+    {
+        scoped_lock with(task->kill_lock);
+        if (task->killed && !threw_exception) {
+            LOG(task, task, "Task killed during termination");
+            threw_exception = true;
+        }
     }
 
     task->notify(!threw_exception);
@@ -244,6 +247,7 @@ void rust_task::start()
 
 bool
 rust_task::must_fail_from_being_killed() {
+    scoped_lock with(kill_lock);
     return killed && !reentered_rust_stack;
 }
 
@@ -275,7 +279,10 @@ rust_task::kill() {
     // If you want to fail yourself you do self->fail().
     LOG(this, task, "killing task %s @0x%" PRIxPTR, name, this);
     // When the task next goes to yield or resume it will fail
-    killed = true;
+    {
+        scoped_lock with(kill_lock);
+        killed = true;
+    }
     // Unblock the task so it can unwind.
     unblock();