about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2012-07-13 19:13:11 -0400
committerBen Blum <bblum@andrew.cmu.edu>2012-07-13 20:13:53 -0400
commitcd38377b1b558ebf53a6401b0baf02e0329ba58b (patch)
treee7d66e3b4d51e5f5f238834724c805047661af4c /src/rt/rust_task.cpp
parent1c0b45785387529c1f8d6313d4b632fae53188c1 (diff)
downloadrust-cd38377b1b558ebf53a6401b0baf02e0329ba58b.tar.gz
rust-cd38377b1b558ebf53a6401b0baf02e0329ba58b.zip
Add asserts to check fail_sched_loop() only once
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index a6c9b791fda..db4db51d3cf 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -129,11 +129,17 @@ cleanup_task(cleanup_args *args) {
         // assert(task->task_local_data != NULL);
         task->task_local_data_cleanup(task->task_local_data);
         task->task_local_data = NULL;
-    } else if (threw_exception) {
+    } else if (threw_exception && task->id == INIT_TASK_ID) {
         // Edge case: If main never spawns any tasks, but fails anyway, TLS
         // won't be around to take down the kernel (task.rs:kill_taskgroup,
         // rust_task_kill_all). Do it here instead.
+        // (Note that children tasks can not init their TLS if they were
+        // killed too early, so we need to check main's task id too.)
         task->fail_sched_loop();
+        // This must not happen twice.
+        static bool main_task_failed_without_spawning = false;
+        assert(!main_task_failed_without_spawning);
+        main_task_failed_without_spawning = true;
     }
 
     // FIXME (#2676): For performance we should do the annihilator