# New Ticket Created by  Jürgen Bömmels 
# Please include the string:  [perl #18106]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=18106 >


I think I triggered a bug somewhere in the GC-code but I failed to
find it. When doing several PIO_printf calls parrot segfaults in
get_free_buffer. Strange enough only about 80 calls are necessary to
segfault, but 5000 generations of life.pbc run correct.

Attached is test (patch to t/src/sprintf.t) and a backtrace of the
segfault.



-- attachment  1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/40608/32744/484358/printf.diff

-- attachment  2 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/40608/32745/0c1dad/printf.gdb

Index: t/src/sprintf.t
===================================================================
RCS file: /cvs/public/parrot/t/src/sprintf.t,v
retrieving revision 1.7
diff -u -r1.7 sprintf.t
--- t/src/sprintf.t	27 Oct 2002 11:57:15 -0000	1.7
+++ t/src/sprintf.t	27 Oct 2002 22:19:49 -0000
@@ -1,6 +1,6 @@
 #! perl -w
 
-use Parrot::Test tests => 1;
+use Parrot::Test tests => 2;
 
 TODO: {
     local $TODO="t/src doesn't work on Windows" if $^O =~ /Win32/;
@@ -133,4 +133,24 @@
 -0000001 == -0000001
 That's all, folks!
 OUTPUT
+
+c_output_like (<<'CODE', "[0-9a-f]*\nok\n", "many printfs");
+#include <stdio.h>
+#include "parrot/parrot.h"
+#include "parrot/embed.h"
+
+int main ()
+{
+    INTVAL i;
+    struct Parrot_Interp *interp = NULL;
+
+    interp = Parrot_new ();
+
+    for (i=0; i<10000; i++) {
+         PIO_printf(interp, "%x", i);
+    }
+
+    return 0;
+}
+CODE
 }
GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-suse-linux-gnu"...
(gdb) run
Starting program: /usr/local/src/cvs/parrot/t/src/sprintf_2 
0123456789abcdef101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40414243444546474849
Program received signal SIGSEGV, Segmentation fault.
0x80be2a4 in get_free_buffer (interpreter=0x8129c28, pool=0x8136910)
    at headers.c:113
113         pool->free_list = *(void **)buffer;
(gdb) bt
#0  0x80be2a4 in get_free_buffer (interpreter=0x8129c28, pool=0x8136910)
    at headers.c:113
#1  0x80be646 in new_string_header (interpreter=0x8129c28, flags=512)
    at headers.c:263
#2  0x807785c in string_make (interpreter=0x8129c28, buffer=0xbfffe591, 
    buflen=1, encoding=0x80ec840, flags=512, type=0x80ece1c) at string.c:206
#3  0x80bf812 in uint_to_str (interpreter=0x8129c28, out=0x813e3c8, 
    tc=0xbfffe590 "a4", num=0, base=16 '\020') at spf_render.c:58
#4  0x80c03f6 in Parrot_sprintf_format (interpreter=0x8129c28, pat=0x813e418, 
    obj=0xbffff5d0) at spf_render.c:511
#5  0x80bf428 in Parrot_vsprintf_s (interpreter=0x8129c28, pat=0x813e418, 
    args=0xbffff65c "\216\225\004\b(\234\022\bJ") at misc.c:40
#6  0x80bf46e in Parrot_vsprintf_c (interpreter=0x8129c28, pat=0x80d64db "%x", 
    args=0xbffff658 "J") at misc.c:50
#7  0x8050306 in PIO_printf (interpreter=0x8129c28, s=0x80d64db "%x")
    at io/io.c:639
#8  0x80495b6 in main () at t/src/sprintf_2.c:13
(gdb) quit
The program is running.  Exit anyway? (y or n) 

Reply via email to