bug-gdb
[Top][All Lists]
Advanced

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

Gdb hangs detaching from a threaded program


From: Bruce Karsh
Subject: Gdb hangs detaching from a threaded program
Date: Mon, 22 Oct 2001 12:55:36 -0700

When I attach to a threaded program, run it for a while, and then detach or
quit from it, gdb hangs.  I.e., it cannot be killed with ctl-c and it
doesn't offer a command prompt.

Here's an example session:

gdb testgdb 8974
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 "sparc-sun-solaris2.6"...
(no debugging symbols found)...

/home/bkarsh/TESTGDB/8974: No such file or directory.
Attaching to program `/home/bkarsh/TESTGDB/testgdb', process 8974
Reading symbols from /usr/lib/libpthread.so.1...(no debugging symbols
found)...
done.
Reading symbols from /usr/lib/libc.so.1...(no debugging symbols
found)...done.
Reading symbols from /usr/lib/libdl.so.1...(no debugging symbols
found)...done.
Reading symbols from /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1...
(no debugging symbols found)...done.
Reading symbols from /usr/lib/libthread.so.1...(no debugging symbols
found)...
done.
sol-thread active.
Symbols already loaded for /usr/lib/libpthread.so.1
Symbols already loaded for /usr/lib/libc.so.1
Symbols already loaded for /usr/lib/libdl.so.1
Symbols already loaded for /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
Symbols already loaded for /usr/lib/libthread.so.1
0xff317088 in door_restart () from /usr/lib/libc.so.1
(gdb) c
Continuing.
^C[New Thread 4 (LWP 4)]
[Switching to Thread 4 (LWP 4)]

Program received signal SIGINT, Interrupt.
0xff31653c in _libc_nanosleep () from /usr/lib/libc.so.1
(gdb) detach

<At this point, it is hung>

This is on a Solaris 5.7 system:

SunOS ec007 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-60

Here's a test program that hangs when debugged:

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

#define NTIDS 7

void *start_func(void *arg);

main()
{
    pthread_attr_t attr;
    pthread_t      tid[NTIDS];
    void           *arg;
    int            i;

    setbuf(stdout,0);
    pthread_attr_init(&attr);
    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
    for(i=0;i<NTIDS;i++) {
        arg=(void *)(100+i);
        pthread_create(&tid[i], &attr, start_func, arg);
    }
    for(i=0;i<NTIDS;i++) {
        pthread_join(tid[i], &arg);
    }
}

void *
start_func(void *arg)
{
    int num;
    num = (int) arg;
    while(1) {
        printf("num=%d\n",num);
        sleep(1);
    }
    pthread_exit(arg);
}

Here's the Makefile:

testgdb:        testgdb.c
        cc -lpthread testgdb.c -o testgdb
clean:
        rm testgdb





reply via email to

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