On Mon, Aug 12, 2002 at 03:56:27AM -0400, Mike Lambert wrote:

Here is a workaround for one hash related GC bug.

-- 
Jason
Index: hash.c
===================================================================
RCS file: /cvs/public/parrot/hash.c,v
retrieving revision 1.19
diff -u -r1.19 hash.c
--- hash.c      7 Aug 2002 20:27:53 -0000       1.19
+++ hash.c      12 Aug 2002 20:00:16 -0000
@@ -285,6 +285,7 @@
 new_hash(Interp *interpreter)
 {
     HASH *hash = (HASH *)new_bufferlike_header(interpreter, sizeof(*hash));
+       volatile Buffer *for_gc;
     /*      hash->buffer.flags |= BUFFER_report_FLAG; */
 
     /* We rely on the fact that expand_hash() will be called before
@@ -295,7 +296,12 @@
     hash->max_chain = (HashIndex) -1;
 
     hash->entries = 0;
-    hash->bucket_pool = new_buffer_header(interpreter);
+
+    /* In order to keep the bucket_pool header from being
+     * collected from expand_hash(), a pointer to it is put on
+     * the system stack where the stack walking code can find it */
+    for_gc = hash->bucket_pool = new_buffer_header(interpreter);
+
     /*      hash->bucket_pool->flags |= BUFFER_report_FLAG; */
     hash->free_list = NULLBucketIndex;
     expand_hash(interpreter, hash);

Reply via email to