NetBSD Problem Report #54029

From gson@gson.org  Fri Mar  1 16:56:30 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 84A8C7A174
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  1 Mar 2019 16:56:30 +0000 (UTC)
Message-Id: <20190301165624.148F298B726@guava.gson.org>
Date: Fri,  1 Mar 2019 18:56:24 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: gdb attach says "Couldn't get registers: Device busy"
X-Send-Pr-Version: 3.95

>Number:         54029
>Category:       bin
>Synopsis:       gdb attach says "Couldn't get registers: Device busy"
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 01 17:00:00 +0000 2019
>Last-Modified:  Fri Mar 01 17:20:01 +0000 2019
>Originator:     Andreas Gustafsson
>Release:        NetBSD 8.0, also -current
>Organization:

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

When attaching to a running process with gdb under 8.0 or -current,
it prints the error message "Couldn't get registers: Device busy."

Also, after the attach, there is no "(gdb)" prompt at the end of the
output - instead, it appears several lines above it.

>How-To-Repeat:

# ps -glaxw|grep getty
  0 415  402   275  85  0 11128   520 pipe_rd R+   tty00  0:00.02 grep getty 
  0 398    1   898  85  0 12116  1288 ttyraw  Is+  ttyE1  0:00.09 /usr/libexec/getty Pc ttyE1 
  0 389    1   898  85  0 13212  1288 ttyraw  Is+  ttyE2  0:00.06 /usr/libexec/getty Pc ttyE2 
  0 382    1  1347  85  0 12116  1288 ttyraw  Is+  ttyE3  0:00.06 /usr/libexec/getty Pc ttyE3 

# gdb /usr/libexec/getty
[...verbose output elided...]
(gdb) attach 382 
Attaching to program: /usr/libexec/getty, process 382
Couldn't get registers: Device busy.
(gdb) [New LWP 1 of process 382]
Reading symbols from /usr/lib/libutil.so.7...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libterminfo.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libc.so.12...(no debugging symbols found)...done.
Reading symbols from /usr/libexec/ld.elf_so...(no debugging symbols found)...done.
[Switching to LWP 1 of process 382]
0x0000737c7b63e98a in read () from /usr/lib/libc.so.12

This happens despite disabling various gdb-unfriendly security
features with

  sysctl -w security.pax.mprotect.enabled=0
  sysctl -w security.pax.mprotect.ptrace=0

Despite the error message, gdb does appear to more or less work,
modulo the usual other open gdb bugs, once you realize that it's
actually waiting for your input despite there being no prompt at the
end.

For an example of another user affected by this, see
http://mail-index.netbsd.org/netbsd-users/2019/01/26/msg022112.html

>Fix:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/54029: gdb attach says "Couldn't get registers: Device busy"
Date: Fri, 1 Mar 2019 18:08:20 +0100

 On Fri, Mar 01, 2019 at 05:00:00PM +0000, Andreas Gustafsson wrote:
 > (gdb) attach 382 
 > Attaching to program: /usr/libexec/getty, process 382
 > Couldn't get registers: Device busy.
 > (gdb) [New LWP 1 of process 382]

 Could this depend on various other local settings? It seems to work for me
 in -current:

 Attaching to process 498
 [New LWP 1 of process 498]
 Reading symbols from /usr/libexec/getty...Reading symbols from /usr/libdata/debug//usr/libexec/getty.debug...done.
 done.
 Reading symbols from /usr/lib/libutil.so.7...Reading symbols from /usr/libdata/debug//usr/lib/libutil.so.7.24.debug...done.
 done.
 Reading symbols from /usr/lib/libterminfo.so.1...Reading symbols from /usr/libdata/debug//usr/lib/libterminfo.so.1.0.debug...done.
 done.
 Reading symbols from /usr/lib/libc.so.12...Reading symbols from /usr/libdata/debug//usr/lib/libc.so.12.211.debug...done.
 done.
 Reading symbols from /usr/libexec/ld.elf_so...Reading symbols from /usr/libdata/debug//usr/libexec/ld.elf_so.debug...done.
 done.
 [Switching to LWP 1 of process 498]
 0x00007f7ff703e97a in read () from /usr/lib/libc.so.12
 (gdb) 


 Martin

From: Andreas Gustafsson <gson@gson.org>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@NetBSD.org
Subject: Re: bin/54029: gdb attach says "Couldn't get registers: Device busy"
Date: Fri, 1 Mar 2019 19:17:03 +0200

 Martin Husemann wrote:
 >  Could this depend on various other local settings? It seems to work for me
 >  in -current:

 It could depend on your local settings :)

 It get the error with fresh installs of both 8.0 and -current, where
 ps and gdb are literaly the first two commands run after the first
 login after the install.
 -- 
 Andreas Gustafsson, gson@gson.org

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.