summaryrefslogtreecommitdiff
path: root/ghc/rts/Weak.c
diff options
context:
space:
mode:
authorsimonm <unknown>1999-02-26 12:43:58 +0000
committersimonm <unknown>1999-02-26 12:43:58 +0000
commit284ed5fbb31808846b2ff66f4c44b5d1e9901d46 (patch)
tree4a33a8a8b0d6fc25769f7e1b8d85f46993912f49 /ghc/rts/Weak.c
parent308bf20ecdc36d9990f27a4faf8f4faf20fbc091 (diff)
downloadhaskell-284ed5fbb31808846b2ff66f4c44b5d1e9901d46.tar.gz
[project @ 1999-02-26 12:43:58 by simonm]
Fix bug in finalizeWeakPointersNow - some weak ptrs could be missed.
Diffstat (limited to 'ghc/rts/Weak.c')
-rw-r--r--ghc/rts/Weak.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ghc/rts/Weak.c b/ghc/rts/Weak.c
index 854fcf9856..23c09b94f3 100644
--- a/ghc/rts/Weak.c
+++ b/ghc/rts/Weak.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $Id: Weak.c,v 1.8 1999/02/11 14:22:55 simonm Exp $
+ * $Id: Weak.c,v 1.9 1999/02/26 12:43:58 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
@@ -19,14 +19,19 @@ StgWeak *weak_ptr_list;
* finalizeWeakPointersNow() is called just before the system is shut
* down. It runs the finalizer for each weak pointer still in the
* system.
+ *
+ * Careful here - rts_evalIO might cause a garbage collection, which
+ * might change weak_ptr_list. Must re-load weak_ptr_list each time
+ * around the loop.
*/
void
finalizeWeakPointersNow(void)
{
StgWeak *w;
-
- for (w = weak_ptr_list; w; w = w->link) {
+
+ while ((w = weak_ptr_list)) {
+ weak_ptr_list = w->link;
IF_DEBUG(weak,fprintf(stderr,"Finalising weak pointer at %p -> %p\n", w, w->key));
w->header.info = &DEAD_WEAK_info;
if (w->finalizer != &NO_FINALIZER_closure) {