NetBSD Problem Report #54590

From martin@duskware.de  Tue Oct  1 12:37:05 2019
Return-Path: <martin@duskware.de>
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 53F057A1E1
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  1 Oct 2019 12:37:05 +0000 (UTC)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: running binaries from gdb fails
X-Send-Pr-Version: 3.95

>Number:         54590
>Category:       toolchain
>Synopsis:       running binaries from gdb fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 01 12:40:02 +0000 2019
>Closed-Date:    Tue Apr 21 18:37:16 +0000 2020
>Last-Modified:  Tue Apr 21 18:37:16 +0000 2020
>Originator:     Martin Husemann
>Release:        NetBSD 9.99.15
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD unpluged.duskware.de 9.99.15 NetBSD 9.99.15 (UNPLUGED) #265: Tue Oct 1 13:38:00 CEST 2019 martin@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/evbarm/compile/UNPLUGED evbarm
Architecture: earm
Machine: evbarm
>Description:

Trying to start a binary in the debugger fails:

$ gdb named
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "armv7--netbsdelf-eabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from named...
Reading symbols from /usr/libdata/debug//usr/sbin/named.debug...
(gdb) run
Starting program: /usr/sbin/named 
ptrace: Invalid argument.
(gdb) 

Fails for other binaries too (e.g. /bin/ls).

>How-To-Repeat:
s/a

>Fix:
n/a

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: kamil@NetBSD.org
Subject: Re: toolchain/54590: running binaries from gdb fails
Date: Tue, 1 Oct 2019 16:30:24 +0000

 Same failure mode on amd64.

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: kamil@NetBSD.org
Subject: Re: toolchain/54590: running binaries from gdb fails
Date: Tue, 1 Oct 2019 18:44:32 +0200

 Example ktrace for this issue:

  24228      1 gdb      CALL  execve(0xbfffee18,0xbb8b6070,0xbb89fd00)
  24228      1 gdb      NAMI  "/usr/pkg/bin/tcsh"
  24228      1 gdb      NAMI  "/usr/libexec/ld.elf_so"
  24228      1 tcsh     EMUL  "netbsd"
   7933      1 gdb      RET   __vfork14 24228/0x5ea4
   7933      1 gdb      CALL  __wait450(0x5ea4,0xbfffe18c,0,0)
   7933      1 gdb      RET   __wait450 24228/0x5ea4
   7933      1 gdb      CALL  ptrace(PT_GET_PROCESS_STATE,0x5ea4,0xbfffe190,8)
   7933      1 gdb      RET   ptrace -1 errno 22 Invalid argument

 24228 == 0x5ea4
 and sizeof struct ptrace_state should be == 8.

 So I guess sys_ptrace_common.c:701 strikes and I really don't get how this
 is supposed to work.

 Martin

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@netbsd.org, toolchain-manager@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, martin@NetBSD.org
Cc: 
Subject: Re: toolchain/54590: running binaries from gdb fails
Date: Tue, 1 Oct 2019 14:07:26 -0400

 On Oct 1,  4:45pm, martin@duskware.de (Martin Husemann) wrote:
 -- Subject: Re: toolchain/54590: running binaries from gdb fails

 | The following reply was made to PR toolchain/54590; it has been noted by GNATS.
 | 
 | From: Martin Husemann <martin@duskware.de>
 | To: gnats-bugs@netbsd.org
 | Cc: kamil@NetBSD.org
 | Subject: Re: toolchain/54590: running binaries from gdb fails
 | Date: Tue, 1 Oct 2019 18:44:32 +0200
 | 
 |  Example ktrace for this issue:
 |  
 |   24228      1 gdb      CALL  execve(0xbfffee18,0xbb8b6070,0xbb89fd00)
 |   24228      1 gdb      NAMI  "/usr/pkg/bin/tcsh"
 |   24228      1 gdb      NAMI  "/usr/libexec/ld.elf_so"
 |   24228      1 tcsh     EMUL  "netbsd"
 |    7933      1 gdb      RET   __vfork14 24228/0x5ea4
 |    7933      1 gdb      CALL  __wait450(0x5ea4,0xbfffe18c,0,0)
 |    7933      1 gdb      RET   __wait450 24228/0x5ea4
 |    7933      1 gdb      CALL  ptrace(PT_GET_PROCESS_STATE,0x5ea4,0xbfffe190,8)
 |    7933      1 gdb      RET   ptrace -1 errno 22 Invalid argument
 |  
 |  24228 == 0x5ea4
 |  and sizeof struct ptrace_state should be == 8.
 |  
 |  So I guess sys_ptrace_common.c:701 strikes and I really don't get how this
 |  is supposed to work.

 The trap events reported in eventswitch are:

         KASSERT((code == TRAP_CHLD) || (code == TRAP_LWP) ||
 		(code == TRAP_EXEC));

 But the trap events that can be retrieved in get_process_stats are:

             (t->p_sigctx.ps_info._code != TRAP_CHLD &&
 	    t->p_sigctx.ps_info._code != TRAP_LWP)) {

 (TRAP_EXEC is missing)

 christos

From: "Kamil Rytarowski" <kamil@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54590 CVS commit: src/sys/kern
Date: Tue, 1 Oct 2019 18:44:22 +0000

 Module Name:	src
 Committed By:	kamil
 Date:		Tue Oct  1 18:44:22 UTC 2019

 Modified Files:
 	src/sys/kern: sys_ptrace_common.c

 Log Message:
 Restore the old behavior in PT_GET_PROCESS_STATE

 For !child and !lwp events return zeroed struct ptrace_state.

 There is code that depends on it (GDB).

 Fixes PR toolchain/54590 by martin@


 To generate a diff of this commit:
 cvs rdiff -u -r1.59 -r1.60 src/sys/kern/sys_ptrace_common.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54590 CVS commit: [netbsd-9] src/sys/kern
Date: Tue, 15 Oct 2019 18:38:40 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Tue Oct 15 18:38:40 UTC 2019

 Modified Files:
 	src/sys/kern [netbsd-9]: sys_ptrace_common.c

 Log Message:
 Pull up following revision(s) (requested by kamil in ticket #313):

 	sys/kern/sys_ptrace_common.c: revision 1.60

 Restore the old behavior in PT_GET_PROCESS_STATE
 For !child and !lwp events return zeroed struct ptrace_state.

 There is code that depends on it (GDB).

 Fixes PR toolchain/54590 by martin@


 To generate a diff of this commit:
 cvs rdiff -u -r1.58.2.2 -r1.58.2.3 src/sys/kern/sys_ptrace_common.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: maya@NetBSD.org
State-Changed-When: Tue, 21 Apr 2020 17:34:23 +0000
State-Changed-Why:
Is the issue fixed by the commit? thanks.


State-Changed-From-To: feedback->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Tue, 21 Apr 2020 18:37:16 +0000
State-Changed-Why:
fixed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.