NetBSD Problem Report #54508

From tobiasu@tmux.org  Thu Aug 29 17:27:57 2019
Return-Path: <tobiasu@tmux.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 68EBA7A176
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 29 Aug 2019 17:27:57 +0000 (UTC)
Message-Id: <20190829172753.6437D1B67E5@nbsd1.tmux.org>
Date: Thu, 29 Aug 2019 17:27:53 +0000 (UTC)
From: tobiasu@tmux.org
Reply-To: tobiasu@tmux.org
To: gnats-bugs@NetBSD.org
Subject: gdb watch variable backgrounds gdb
X-Send-Pr-Version: 3.95

>Number:         54508
>Category:       toolchain
>Synopsis:       'watch'ing a variable backgrounds gdb process
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kamil
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 29 17:30:00 +0000 2019
>Closed-Date:    Fri Sep 06 19:59:53 +0000 2019
>Last-Modified:  Fri Sep 06 19:59:53 +0000 2019
>Originator:     Tobias Ulmer
>Release:        NetBSD 9.99.10
>Organization:

>Environment:


System: NetBSD nbsd1.tmux.org 9.99.10 NetBSD 9.99.10 (GENERIC) #0: Sat Aug 24 11:51:26 UTC 2019 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
This is a bit of a WTF.  Watching a variable in gdb sends the gdb process into
the (terminal) background. Recovery (with fg) is not possible.  Does not depend
on the program, volatile in the example is just to stop optimization.
>How-To-Repeat:
$ echo "int main(void) { volatile int x; return 0; }" > gt.c
$ gcc -ggdb gt.c
$ gdb ./a.out
(gdb) break main
Breakpoint 1 at 0x40092e: file gt.c, line 1.
(gdb) run
Starting program: /home/tobiasu/a.out 

Breakpoint 1, main () at gt.c:1
1       int main(void) { volatile int x; return 0; }
(gdb) watch x
Hardware watchpoint 2: x
(gdb) step
[1] + Stopped (tty output) gdb ./a.out 
$ fg
gdb ./a.out 
[1] + Stopped (tty output) gdb ./a.out 
$ fg
gdb ./a.out 
[1] + Stopped (tty output) gdb ./a.out 
$ kill -9 %1
$ [ 96995.7464743] sorry, pid 12282 was killed: orphaned traced process
[1] + Killed               gdb ./a.out
>Fix:

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: toolchain-manager->kamil
Responsible-Changed-By: kamil@NetBSD.org
Responsible-Changed-When: Fri, 06 Sep 2019 00:51:59 +0200
Responsible-Changed-Why:
take


From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: Kamil Rytarowski <kamil@netbsd.org>,
 toolchain-manager@netbsd.org,
 netbsd-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 tobiasu@tmux.org
Subject: Re: toolchain/54508 ('watch'ing a variable backgrounds gdb process)
Date: Thu, 5 Sep 2019 19:48:49 -0400

 This seems to work for me on HEAD.

 christos

From: Kamil Rytarowski <n54@gmx.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/54508 ('watch'ing a variable backgrounds gdb process)
Date: Fri, 6 Sep 2019 01:53:59 +0200

 On 06.09.2019 01:50, Christos Zoulas wrote:
 > The following reply was made to PR toolchain/54508; it has been noted by=
  GNATS.
 >
 > From: Christos Zoulas <christos@zoulas.com>
 > To: gnats-bugs@netbsd.org
 > Cc: Kamil Rytarowski <kamil@netbsd.org>,
 >  toolchain-manager@netbsd.org,
 >  netbsd-bugs@netbsd.org,
 >  gnats-admin@netbsd.org,
 >  tobiasu@tmux.org
 > Subject: Re: toolchain/54508 ('watch'ing a variable backgrounds gdb proc=
 ess)
 > Date: Thu, 5 Sep 2019 19:48:49 -0400
 >
 >  This seems to work for me on HEAD.
 >
 >  christos
 >
 >

 I can reproduce it on 9.99.11.

 Investigating.

From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: Kamil Rytarowski <kamil@netbsd.org>,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 tobiasu@tmux.org
Subject: Re: toolchain/54508 ('watch'ing a variable backgrounds gdb process)
Date: Thu, 5 Sep 2019 19:59:59 -0400

 Ah I got it. Works as root... :-)

 christos

From: Kamil Rytarowski <n54@gmx.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: toolchain/54508 ('watch'ing a variable backgrounds gdb process)
Date: Fri, 6 Sep 2019 02:06:49 +0200

 On 06.09.2019 01:59, Christos Zoulas wrote:
 > Ah I got it. Works as root... :-)
 >
 > christos
 >

 Right.

 There is need to add detection of
 security.models.extensions.user_set_dbregs.

 Basically transplant this code into GDB:

 https://nxr.netbsd.org/xref/src/tests/lib/libc/sys/t_ptrace_wait.h#528

 I will add it.

State-Changed-From-To: open->closed
State-Changed-By: kamil@NetBSD.org
State-Changed-When: Fri, 06 Sep 2019 21:59:53 +0200
State-Changed-Why:
Fixed in HEAD

To generate a diff of this commit:
cvs rdiff -u -r1.1.1.8 -r1.2 src/external/gpl3/gdb/dist/gdb/ChangeLog \
    src/external/gpl3/gdb/dist/gdb/event-top.c \
    src/external/gpl3/gdb/dist/gdb/ser-unix.c \
    src/external/gpl3/gdb/dist/gdb/top.c
cvs rdiff -u -r1.1.1.7 -r1.2 src/external/gpl3/gdb/dist/gdb/inflow.c \
    src/external/gpl3/gdb/dist/gdb/inflow.h

Pulled to NetBSD-9 #188

external/gpl3/gdb/dist/gdb/ChangeLog            1.2
external/gpl3/gdb/dist/gdb/event-top.c          1.2
external/gpl3/gdb/dist/gdb/inflow.c             1.2
external/gpl3/gdb/dist/gdb/inflow.h             1.2
external/gpl3/gdb/dist/gdb/ser-unix.c           1.2
external/gpl3/gdb/dist/gdb/top.c                1.2

        PR toolchain/54508: cherry-pick upstream GDB patch to fix SIGTTOU
        handling.



>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.