bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pthread_exit from initial thread makes GDB hang


From: Ben Pfaff
Subject: pthread_exit from initial thread makes GDB hang
Date: Tue, 18 Dec 2007 09:11:11 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Under Debian GNU/Linux "unstable", with a Debian
2.6.22-1-686-bigmem kernel, the following program hangs GDB 6.7.1
(as packaged for Debian under Debian version number 6.7.1-1) if
one types control-C to break out to the debugger:

    #include <pthread.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>

    void *my_thread(void *foo) 
    {
        for (;;) {
            sleep(1);
            putchar('.');
            fflush(stdout);
        }
    }

    int main(void) 
    {
        pthread_t pth;
        pthread_create(&pth, NULL, my_thread, NULL);
        pthread_detach(pthread_self());
        pthread_exit(0);
    }

If the final two statements in main are changed to
        for (;;)
          pause();
then GDB can break out as expected.
-- 
Ben Pfaff 
http://benpfaff.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]