If I run this code, which should just be a loop which creates-then-joins a thread (looping twice), I get a crash at the end:

    set I16, 0
again:
    inc I16
    new P5, .ParrotThread
    find_global P6, "_foo"
    find_method P0, P5, "thread3"
    invoke
    set I5, P5
    getinterp P2
    find_method P0, P2, "join"
    invoke
    lt I16, 2, again
    print "done\n"
    end

.pcc_sub _foo:
    invoke P1


The problem is that when joining the _second_ time, in pt_thread_join() you get a return value from joining the thread--which happens to contain a thread-interpreter PMC:


(gdb) p (char*)((PMC*)retval)->vtable->isa_str->strstart
$2 = 0x1dc40c "ParrotThread ParrotInterpreter"

This then gets cloned, which ultimately ends up messing up the interpreter_array[] (things end up in the wrong slot), and pt_join_threads() ends up trying to join a bogus thread, and you get a crash.

So, the bug seems to be that the second time through, you get a return value from the thread. I don't know why this is happening--haven't tried digging yet.

JEff



Reply via email to