NetBSD-Bugs archive

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

bin/54375: gdb attached to running process shows extra thread



>Number:         54375
>Category:       bin
>Synopsis:       gdb attached to running process shows extra thread
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 14 10:50:00 +0000 2019
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current, source date 2019.06.17.17.53.41
>Organization:

>Environment:
System: NetBSD
Architecture: x86_64
Machine: amd64
>Description:

When attaching gdb to a running threaded process, "info threads" shows
one of the threads twice, so that the total number of threads shown is
one more than the actual number.

>How-To-Repeat:

$ cat <<EOF >test.c
#include <unistd.h>
#include <pthread.h>
void *t(void *arg) {
  pause();
}
int main(int argc, char **argv) {
   pthread_t thread;
   pthread_create(&thread, 0, t, 0);
   pause();
}
EOF
$ cc test.c -lpthread -o test
$ ./test &
$ gdb ./test $!
(gdb) info threads

This shows three threads, even though the process has only two:

 Id   Target Id               Frame 
* 1    process 523 ""          0x000073b66be427da in _sys___sigsuspend14 () from /usr/lib/libc.so.12
  2    LWP 2 of process 523 "" 0x000073b66be427da in _sys___sigsuspend14 () from /usr/lib/libc.so.12
  3    LWP 1 of process 523 "" 0x000073b66be427da in _sys___sigsuspend14 () from /usr/lib/libc.so.12

If the program is started from within gdb instead of attaching to a
process already running, only two threads are shown:

$ gdb ./test
(gdb) run
^C
(gdb) info threads
  Id   Target Id               Frame 
  1    LWP 1 of process 979 "" 0x0000737a876427da in _sys___sigsuspend14 () from /usr/lib/libc.so.12
* 2    LWP 2 of process 979 "" 0x0000737a876427da in _sys___sigsuspend14 () from /usr/lib/libc.so.12

>Fix:



Home | Main Index | Thread Index | Old Index