NetBSD Problem Report #54375
From gson@gson.org Sun Jul 14 10:47:15 2019
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 30C0F7A1BB
for <gnats-bugs@gnats.NetBSD.org>; Sun, 14 Jul 2019 10:47:15 +0000 (UTC)
Message-Id: <20190714104709.4F8A19896B7@guava.gson.org>
Date: Sun, 14 Jul 2019 13:47:09 +0300 (EEST)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: gdb attached to running process shows extra thread
X-Send-Pr-Version: 3.95
>Number: 54375
>Category: bin
>Synopsis: gdb attached to running process shows extra thread
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jul 14 10:50:00 +0000 2019
>Closed-Date: Mon Jul 15 13:00:14 +0000 2019
>Last-Modified: Mon Jul 15 13:00:14 +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:
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/54375 CVS commit: src/external/gpl3/gdb/dist/gdb
Date: Sun, 14 Jul 2019 14:50:58 -0400
Module Name: src
Committed By: christos
Date: Sun Jul 14 18:50:58 UTC 2019
Modified Files:
src/external/gpl3/gdb/dist/gdb: nbsd-nat.c
Log Message:
PR/54375: Andreas Gustafsson: gdb attached to running process shows extra
thread. When attaching to a process that has threads make sure that we
mutate the inferior_ptid (that currently has lwpid == 0 to the first thread
we encounter.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/gpl3/gdb/dist/gdb/nbsd-nat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 14 Jul 2019 23:31:36 +0000
State-Changed-Why:
fixed?
State-Changed-From-To: feedback->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Mon, 15 Jul 2019 13:00:14 +0000
State-Changed-Why:
Fixed, thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.