X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FTask.c;h=4301ab4b59f7520cae055048eed9cd97f0d5a6ab;hb=cd2c71bb9bfe5dd3582263468712c29192c7340e;hp=4a630843b725cec6aa1afaff7e26417dac2a06ae;hpb=1f801e3abd16559f2120b7f482b19deb0c43a0c7;p=ghc-hetmet.git diff --git a/rts/Task.c b/rts/Task.c index 4a63084..4301ab4 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -84,12 +84,18 @@ freeTaskManager (void) ACQUIRE_LOCK(&sched_mutex); for (task = all_tasks; task != NULL; task = next) { + next = task->all_link; + if (task->stopped) { + // We only free resources if the Task is not in use. A + // Task may still be in use if we have a Haskell thread in + // a foreign call while we are attempting to shut down the + // RTS (see conc059). #if defined(THREADED_RTS) - closeCondition(&task->cond); - closeMutex(&task->lock); + closeCondition(&task->cond); + closeMutex(&task->lock); #endif - next = task->all_link; - stgFree(task); + stgFree(task); + } } all_tasks = NULL; task_free_list = NULL;