boundTaskExiting: don't set task->stopped unless this is the last call (#4850)
[ghc-hetmet.git] / rts / Task.c
index a15758c..a5de804 100644 (file)
@@ -270,8 +270,6 @@ newBoundTask (void)
 void
 boundTaskExiting (Task *task)
 {
-    task->stopped = rtsTrue;
-
 #if defined(THREADED_RTS)
     ASSERT(osThreadId() == task->id);
 #endif
@@ -279,6 +277,14 @@ boundTaskExiting (Task *task)
 
     endInCall(task);
 
+    // Set task->stopped, but only if this is the last call (#4850).
+    // Remember that we might have a worker Task that makes a foreign
+    // call and then a callback, so it can transform into a bound
+    // Task for the duration of the callback.
+    if (task->incall == NULL) {
+        task->stopped = rtsTrue;
+    }
+
     debugTrace(DEBUG_sched, "task exiting");
 }