----- Original Message -----
From: "Melvin Smith" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "dan Sugalski" <[EMAIL PROTECTED]>
Sent: 26 March 2002 09:39
Subject: [PATCH] Stack bugfix


>
> Afterwards the test program ran with larger file sizes, eventually
> crashing again, but this time in the GC. <*PUNT* Dan goes back to the 10
> yard line.....>
>
> ../parrot reverse.pbc < string.c
>
> <file prints out pre-reverse call>
>
> recurse depth 0
> Segmentation fault (core dumped)
>

This seems to caused by a nice timing problem - the string header has been
allocated, then attempting to allocate the string buffer triggers a garbage
collection. The string header still points to wherever it did before it was
freed, and has already been marked as live, so the GC code tries to copy the
old buffer contents to the new memory pool.

Patch below fixes it by clearing the buffer pointer on allocation of a new
header; it could alternatively be done when the header is added to the free
list.

--
Peter Gibbs
EmKel Systems


Index: resources.c
===================================================================
RCS file: /home/perlcvs/parrot/resources.c,v
retrieving revision 1.35
diff -u -r1.35 resources.c
--- resources.c 26 Mar 2002 16:33:01 -0000      1.35
+++ resources.c 27 Mar 2002 07:38:48 -0000
@@ -645,6 +645,8 @@
     interpreter->active_Buffers++;
     /* Mark it live */
     return_me->flags = BUFFER_live_FLAG;
+    /* Make sure it doesn't point anywhere yet */
+    return_me->bufstart = NULL;
     /* Return it */
     return return_me;
   }


Reply via email to