# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #31806]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=31806 >


---
osname= freebsd
osvers= 5.2-beta
arch=   i386-freebsd
cc=     cc 
---
Flags:
    category=core
    severity=high
    ack=no
---
This started out as me trying to build parrot on FreeBSD, and finding it fails
tests due to a double free() warning not matching "expected" results.
(Also fails on OS X as its malloc() has automatic double free() warnings)

So I had a dig (valgrind on FreeBSD++), and it turns out that it's this line:

    mem_sys_free(pio_registered_layers);

in PIO_finish.

gdb traceback:

Starting program: /home/nick/Parrot/parrot04/parrot t/op/interp_1.pasm
calling
In 2
ending

Breakpoint 1, PIO_finish (interpreter=0x8553c00) at io/io.c:325
325         for (layer = interpreter->piodata->default_stack; layer; ) {
(gdb) where
#0  PIO_finish (interpreter=0x8553c00) at io/io.c:325
#1  0x0809993b in Parrot_really_destroy (exit_code=0, vinterp=0x8553c00)
    at src/inter_create.c:333
#2  0x080e0e4a in Parrot_exit (status=0) at src/exit.c:79
#3  0x0809949e in main (argc=1, argv=0xbfbfec08) at imcc/main.c:587
#4  0x08098112 in _start ()
(gdb) c
Continuing.

Breakpoint 1, PIO_finish (interpreter=0x82ee400) at io/io.c:325
325         for (layer = interpreter->piodata->default_stack; layer; ) {
(gdb) where
#0  PIO_finish (interpreter=0x82ee400) at io/io.c:325
#1  0x0809993b in Parrot_really_destroy (exit_code=0, vinterp=0x82ee400)
    at src/inter_create.c:333
#2  0x080e0e4a in Parrot_exit (status=0) at src/exit.c:79
#3  0x0809949e in main (argc=1, argv=0xbfbfec08) at imcc/main.c:587
#4  0x08098112 in _start ()
(gdb) c
Continuing.
parrot in free(): warning: chunk is already free


It's being called from the same place, but for 2 different interpreters.
At first I was just going to patch it with:

    pio_registered_layers = NULL;

after the free(), but than I thought "This is a bug, because I guess we
want to free it with the *last* interpreter, not the first".

But then I thought


   AWOOGA! AWOOGA! GLOBAL VARIABLE. NOT IN AN INTERPRETER STRUCTURE.


And I'm not sure what the correct fix is. But it sure ain't threadsafe
currently.

Nicholas Clark
---
Summary of my parrot 0.1.0 configuration:
  configdate='Sat Oct  2 10:23:19 2004'
  Platform:
    osname=freebsd, archname=i386-freebsd
    jitcapable=1, jitarchname=i386-freebsd,
    jitosname=FREEBSD, jitcpuarch=i386
    execcapable=1
    perl=/usr/bin/perl
  Compiler:
    cc='cc', ccflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.6.1/BSDPAN"  
-I/usr/local/include',
  Linker and Libraries:
    ld='cc', ldflags='-Wl,-E  -L/usr/local/lib',
    cc_ldflags='',
    libs='-lm -lcrypt -lutil -lc_r -lgmp'
  Dynamic Linking:
    so='.so', ld_shared='-shared  -L/usr/local/lib',
    ld_shared_flags=''
  Types:
    iv=long, intvalsize=4, intsize=4, opcode_t=long, opcode_t_size=4,
    ptrsize=4, ptr_alignment=1 byteorder=1234, 
    nv=double, numvalsize=8, doublesize=8

---
Environment:
    HOME    LANG    LANGUAGE    LD_LIBRARY_PATH    LOGDIR    PATH    SHELL

Reply via email to