summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rts/Task.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/rts/Task.c b/rts/Task.c
index a15758c4f1..a5de804418 100644
--- a/rts/Task.c
+++ b/rts/Task.c
@@ -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");
}