summaryrefslogtreecommitdiff
path: root/rts/Weak.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2010-05-05 11:49:47 +0000
committerSimon Marlow <marlowsd@gmail.com>2010-05-05 11:49:47 +0000
commit497f8aa6c2c8770daf3d39f57ee5e04dcdcc3778 (patch)
tree977b2376b794783041e795ee69f69765bf86ca86 /rts/Weak.c
parent7f148c3265edb930223f50c3702e33bc51f00bd1 (diff)
downloadhaskell-497f8aa6c2c8770daf3d39f57ee5e04dcdcc3778.tar.gz
Make the running_finalizers flag task-local
Fixes a bug reported by Lennart Augustsson, whereby we could get an incorrect error from the RTS about re-entry from a finalizer,
Diffstat (limited to 'rts/Weak.c')
-rw-r--r--rts/Weak.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/rts/Weak.c b/rts/Weak.c
index 94bead3752..5546514243 100644
--- a/rts/Weak.c
+++ b/rts/Weak.c
@@ -21,9 +21,6 @@
StgWeak *weak_ptr_list;
-// So that we can detect when a finalizer illegally calls back into Haskell
-rtsBool running_finalizers = rtsFalse;
-
void
runCFinalizer(void *fn, void *ptr, void *env, StgWord flag)
{
@@ -37,8 +34,12 @@ void
runAllCFinalizers(StgWeak *list)
{
StgWeak *w;
+ Task *task;
- running_finalizers = rtsTrue;
+ task = myTask();
+ if (task != NULL) {
+ task->running_finalizers = rtsTrue;
+ }
for (w = list; w; w = w->link) {
StgArrWords *farr;
@@ -52,7 +53,9 @@ runAllCFinalizers(StgWeak *list)
farr->payload[3]);
}
- running_finalizers = rtsFalse;
+ if (task != NULL) {
+ task->running_finalizers = rtsFalse;
+ }
}
/*
@@ -78,8 +81,12 @@ scheduleFinalizers(Capability *cap, StgWeak *list)
StgMutArrPtrs *arr;
StgWord size;
nat n, i;
+ Task *task;
- running_finalizers = rtsTrue;
+ task = myTask();
+ if (task != NULL) {
+ task->running_finalizers = rtsTrue;
+ }
// count number of finalizers, and kill all the weak pointers first...
n = 0;
@@ -114,7 +121,9 @@ scheduleFinalizers(Capability *cap, StgWeak *list)
SET_HDR(w, &stg_DEAD_WEAK_info, w->header.prof.ccs);
}
- running_finalizers = rtsFalse;
+ if (task != NULL) {
+ task->running_finalizers = rtsFalse;
+ }
// No finalizers to run?
if (n == 0) return;