Chromatic <[EMAIL PROTECTED]> wrote:
> (gdb) bac

This is the main thread, that has suspended itself during exit
processing.

> #0  0x0ff976a4 in __pthread_sigsuspend () from /lib/libpthread.so.0
...
> #3  0x0fd0a694 in exit () from /lib/libc.so.6

> (gdb) thread 2

That's the thread-manager thread. It has sent the event thread a
sig_cancel signal and is now waiting on the event thread to terminate:

> #1  0x0ff9c128 in waitpid () from /lib/libpthread.so.0
> #2  0x0ff958d0 in pthread_handle_exit () from /lib/libpthread.so.0
> #3  0x0ff94c90 in __pthread_manager () from /lib/libpthread.so.0

> (gdb) thread 3

And finally the event handler thread, which seems to hang in waiting for
the condition. WTF it doesn't get the cancel signal, sent by the
thread-manager?

> #0  0x0ff976a4 in __pthread_sigsuspend () from /lib/libpthread.so.0
> #1  0x0ff973e0 in __pthread_wait_for_restart_signal ()
>    from /lib/libpthread.so.0
> #2  0x0ff93f9c in [EMAIL PROTECTED] () from
> /lib/libpthread.so.0
> #3  0x101d7614 in queue_wait (queue=0x10279e30) at src/tsq.c:159
> #4  0x1009c968 in event_thread (data=0x10279e30) at src/events.c:349


> and the fact that the attached patch seems to fix things.  I don't
> expect that it's correct.

I don't know, why it seems to fix things. Parrot_new_terminate_event()
places a "stop the run-loop" event into this interpreter's task queue.
It doesn *not* effect the hanging event thread. But it seems to trigger
something in an odd way, so that threads can make some progress and
terminate finally. Really strange.
I don't not even know, if your inserted line is executed, as it seems that
exit() was called somewhere else.

OTOH some lines later (interpreter.c:1143) the main thread tells the
event thread to terminate by Parrot_kill_event_loop(), which pushes an
event into the event queue. This also signals the waiting event thread,
that something arrives, so it should wake up and finally terminate the
event handler thread.

I think, a better solution is to just call Parrot_exit() instead of
exit(), so that Parrot_kill_event_loop() is run.

leo

Reply via email to