NetBSD Problem Report #54820

From martin@duskware.de  Wed Jan  1 11:17:05 2020
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 9F44A7A14B
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  1 Jan 2020 11:17:05 +0000 (UTC)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: gdb broken
X-Send-Pr-Version: 3.95

>Number:         54820
>Category:       toolchain
>Synopsis:       gdb broken
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 01 11:20:00 +0000 2020
>Closed-Date:    Wed Apr 29 15:54:01 +0000 2020
>Last-Modified:  Wed Apr 29 15:54:01 +0000 2020
>Originator:     Martin Husemann
>Release:        NetBSD 9.99.31
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD space-truckin.duskware.de 9.99.31 NetBSD 9.99.31 (GENERIC) #30: Tue Dec 31 14:55:51 CET 2019 martin@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/evbarm/compile/GENERIC evbarm
Architecture: earmv7hfeb
Machine: evbarm
>Description:

Trying to attach to a life process and getting a backtrace
fails:

# gdb -p 695
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 "armv7eb--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".
Attaching to process 695
Reading symbols from /usr/tests/kernel/h_ps_strings2...
Reading symbols from /usr/libdata/debug//usr/tests/kernel/h_ps_strings2.debug...
Reading symbols from /usr/lib/libc.so.12...
Reading symbols from /usr/libdata/debug//usr/lib/libc.so.12.214.debug...
Reading symbols from /usr/libexec/ld.elf_so...
Reading symbols from /usr/libdata/debug//usr/libexec/ld.elf_so.debug...
[Switching to LWP 1 of process 695]
0x792fa1bc in _sys___nanosleep50 () from /usr/lib/libc.so.12
(gdb) bt
#0  0x792fa1bc in _sys___nanosleep50 () from /usr/lib/libc.so.12
terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
#1  0x79235a04 in _sleep (

and then gdb hangs (the incomplete line is not a copy + paste error when
filling this PR).

>How-To-Repeat:
not sure, gdb -p to a non-threaded process in -current on evbarmv7hf-eb?

>Fix:
n/a

>Release-Note:

>Audit-Trail:
From: Rin Okuyama <rokuyama.rk@gmail.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: toolchain/54820 gdb broken
Date: Wed, 29 Apr 2020 19:54:36 +0900

 Hi,

 I found similar crashes occur also for earmv7hf (little endian), and
 simple single-stepping like this:

 ------------------------------------------------------------
 # uname -p
 earmv7hf
 # gdb ./hello
 GNU gdb (GDB) 8.3
 ...snip...
 Reading symbols from ./hello...
 (gdb) b main
 Breakpoint 1 at 0x106ac: file hello.c, line 7.
 (gdb) r
 Starting program: /root/hello

 Breakpoint 1, main () at hello.c:7
 7               printf("Hello, World!\n");
 (gdb) s
 puts (s=0x1077c "Hello, World!") at /build/src/lib/libc/stdio/puts.c:61
 61              const void *vs = s;
 ...snip...
 __flockfile_internal (fp=fp@entry=0xf0608bf8 <__sF+88>,
      internal=internal@entry=1) at /build/src/lib/libc/stdio/flockfile.c:100
 100             if (__isthreaded == 0)
 (gdb) s
 terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
 puts ([ 272534.1561499] sorry, pid 12856 was killed: orphaned traced process
 [1]   Abort trap (core dumped) gdb ./hello
 ------------------------------------------------------------

 However, this does not occur for earmv7{,eb} nor earmv6hf{,eb}. Also,
 gdb does not crash when compiled with GCC8 and -O0, or GCC7 and -O2.

 Finally, I found that single file, dwarf2expr.c, is miscompiled with
 GCC 8.4 with -O[12]. I will commit a workaround and document it in
 doc/HACKS.

 Thanks,
 rin

From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54820 CVS commit: src/external/gpl3/gdb/lib/libgdb
Date: Wed, 29 Apr 2020 11:04:59 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Wed Apr 29 11:04:58 UTC 2020

 Modified Files:
 	src/external/gpl3/gdb/lib/libgdb: Makefile

 Log Message:
 PR toolchain/54820
 PR toolchain/54877

 GCC 8.4 miscompiles dwarf2expr.c with -O2 or -O1 for earmv7hf{,eb}, which
 results in crashes described in the PRs. No upstream fixes up to now. So,
 let us disable optimization for this file.

 Note that this affects only earmv7hf{,eb} as far as I can see. Crashes do
 not occur neither for earmv6hf{,eb} nor earmv7{,eb}.


 To generate a diff of this commit:
 cvs rdiff -u -r1.21 -r1.22 src/external/gpl3/gdb/lib/libgdb/Makefile

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

From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54820 CVS commit: src/doc
Date: Wed, 29 Apr 2020 11:08:40 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Wed Apr 29 11:08:40 UTC 2020

 Modified Files:
 	src/doc: HACKS

 Log Message:
 PR toolchain/54820
 PR toolchain/54877

 earmv7hf{,eb}: compile gdb/dwarf2expr.c with -O0 for GCC8

 http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gdb/lib/libgdb/Makefile#rev1.22


 To generate a diff of this commit:
 cvs rdiff -u -r1.201 -r1.202 src/doc/HACKS

 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: rin@NetBSD.org
State-Changed-When: Wed, 29 Apr 2020 11:11:44 +0000
State-Changed-Why:
Workaround committed. Can you confirm fix?


State-Changed-From-To: feedback->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Wed, 29 Apr 2020 15:54:01 +0000
State-Changed-Why:
works for me


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