summaryrefslogtreecommitdiff
path: root/rts/Schedule.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-11-17 09:43:50 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-11-17 09:43:50 +0000
commitcb90532723bd5801b8ac29973dd14e8e30b1e0a9 (patch)
treeffd87d3d3aca99f07f84c1d71431eb8a66971d00 /rts/Schedule.c
parenta45cf06a9179bab9c6bbc62dab0964e8d325d630 (diff)
downloadhaskell-cb90532723bd5801b8ac29973dd14e8e30b1e0a9.tar.gz
Another shutdown fix
If we encounter a runnable thread during shutdown, just kill it. All the threads are supposed to be dead at this stage, but this catches threads that might have just returned from a foreign call, or were finalizers created by the GC. Fixes memo002(threaded1)
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r--rts/Schedule.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index aedd6b7d80..d25a32186f 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -460,6 +460,15 @@ schedule (Capability *initialCapability, Task *task)
}
#endif
+ // If we're shutting down, and this thread has not yet been
+ // killed, kill it now. This sometimes happens when a finalizer
+ // thread is created by the final GC, or a thread previously
+ // in a foreign call returns.
+ if (sched_state >= SCHED_INTERRUPTING &&
+ !(t->what_next == ThreadComplete || t->what_next == ThreadKilled)) {
+ deleteThread_(cap,t);
+ }
+
/* context switches are initiated by the timer signal, unless
* the user specified "context switch as often as possible", with
* +RTS -C0