NetBSD Problem Report #57337

From www@netbsd.org  Sun Apr  9 14:01:50 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_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 880761A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  9 Apr 2023 14:01:50 +0000 (UTC)
Message-Id: <20230409140148.F1F6B1A923A@mollari.NetBSD.org>
Date: Sun,  9 Apr 2023 14:01:48 +0000 (UTC)
From: uwe@stderr.spb.ru
Reply-To: uwe@stderr.spb.ru
To: gnats-bugs@NetBSD.org
Subject: gdb completely broken on sparc
X-Send-Pr-Version: www-1.0

>Number:         57337
>Category:       port-sparc
>Synopsis:       gdb completely broken on sparc
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 09 14:05:00 +0000 2023
>Last-Modified:  Mon Sep 04 09:15:01 +0000 2023
>Originator:     Valery Ushakov
>Release:        NetBSD 10
>Organization:
>Environment:
NetBSD krups 10.99.2 NetBSD 10.99.2 (KRUPS) #0: Wed Dec 28 02:08:31 MSK 2022  uwe@majava:/home/uwe/work/netbsd/cvs/src/sys/arch/sparc/compile/KRUPS sparc
>Description:
Gdb seems to be completely broken in current.  Unable to get
debuggee registers.

>How-To-Repeat:
$ gdb -q ./hello
Reading symbols from ./hello...
(gdb) b main
Breakpoint 1 at 0x10748: file hello.c, line 6.
(gdb) r
Starting program: /root/hello 

Breakpoint 1, main (
    argc=<error reading variable: Cannot access memory at address 0xf50b1044>, 
    argv=<error reading variable: Cannot access memory at address 0xf50b1048>)
    at hello.c:6
6               printf("%d\n", argc);
(gdb) l
1       #include <stdio.h>
2       
3       int
4       main(int argc, char **argv)
5       {
6               printf("%d\n", argc);
7               return 0;
8       }
(gdb) i r
...
l0             0x65e5e8            6677992
l1             0x65e5e8            6677992
l2             0x65e5e8            6677992
l3             0x65e5e8            6677992
l4             0x65e5e8            6677992
l5             0x65e5e8            6677992
l6             0x65e5e8            6677992
l7             0x65e5e8            6677992
i0             0x65e5e8            6677992
i1             0x65e5e8            6677992
i2             0x65e5e8            6677992
i3             0x65e5e8            6677992
i4             0x65e5e8            6677992
i5             0x65e5e8            6677992
fp             0x65e5e8            0x65e5e8
i7             0x65e5e8            6677992
...

>Fix:

>Audit-Trail:
From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@netbsd.org
Cc: port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org
Subject: re: port-sparc/57337: gdb completely broken on sparc
Date: Mon, 10 Apr 2023 12:38:42 +1000

 weird.  i have different failure mode.

 (gdb) b main
 Breakpoint 1 at 0x10740: file hello.c, line 3.
 (gdb) run
 Starting program: /home/mrg/a.out

 Breakpoint 1, main () at hello.c:3
 3               printf("hello world\n");
 (gdb) i r
 g0             0x0                 0
 g1             0x64                100
 g2             0x1                 1
 g3             0x0                 0
 g4             0xede3a47c          -303848324
 g5             0xeded4aa8          -303215960
 g6             0x0                 0
 g7             0xedec8048          -303267768
 [ ... ]
 psr            0x1e400081          [ S ]
 wim            <unavailable>
 tbr            <unavailable>
 pc             0x10740             0x10740 <main+4>
 npc            0x10744             0x10744 <main+8>
 fsr            0x0                 [ ]

 so i am seeming to get more than you, but then:

 (gdb) step

 Program received signal SIGBUS, Bus error.
 0xeded13b4 in _rtld_bind () from /usr/libexec/ld.elf_so
 (gdb) bt
 #0  0xeded13b4 in _rtld_bind () from /usr/libexec/ld.elf_so
 #1  0x00000012 in ?? ()

 a static binary seems to work differently wrong:

 (gdb) b main
 Breakpoint 2 at 0x1042c: file hello.c, line 3.
 (gdb) r
 Starting program: /home/mrg/a.out

 Breakpoint 2, main () at hello.c:3
 3               printf("hello world\n");
 (gdb) step
 0x00017104 in puts ()
 (gdb) bt
 #0  0x00017104 in puts ()
 #1  0x00010438 in main () at hello.c:3
 Backtrace stopped: previous frame inner to this frame (corrupt stack?)
 (gdb) next
 Single stepping until exit from function puts,
 which has no line number information.
 0x000198d0 in strlen ()


 .mrg.

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: matthew green <mrg@eterna.com.au>
Subject: Re: port-sparc/57337: gdb completely broken on sparc
Date: Mon, 10 Apr 2023 14:52:55 +0300

 Ah, we quote different parts of "info reg".  I also get 

 (gdb) i r
 g0             0x0                 0
 g1             0x64                100
 g2             0x1                 1
 g3             0x0                 0
 g4             0xe5ea4acc          -437630260
 g5             0xe5ed4a90          -437433712
 g6             0x0                 0
 g7             0xe5ec6b58          -437490856
 ...

 for the inital breakpoint, but, significantly, it's the locals and
 inputs that are all messed up.  The static example you quote most
 likely fails for the very same reason, b/c you get junk instead of
 saved return address in %i7 (after window rotation), so it cannot do
 the proper backtrace.

 -uwe

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-sparc/57337: gdb completely broken on sparc
Date: Tue, 29 Aug 2023 16:10:46 +0300

 Import of the new gdb seems to have helped somewhat.  I haven't yet
 tried any heavy duty debugging, but at least the basics seem to work
 again.

 /usr/bin/gdb ./hello
 GNU gdb (GDB) 13.2
 Copyright (C) 2023 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 "sparc--netbsdelf".
 Type "show configuration" for configuration details.
 For bug reporting instructions, please see:
 <https://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 ./hello...
 (gdb) b main
 Breakpoint 1 at 0x10748: file hello.c, line 6.
 (gdb) r
 Starting program: /home/uwe/hello

 Breakpoint 1, main (argc=1, argv=0xe7fff574) at hello.c:6
 6               printf("%d\n", argc);
 (gdb) i r
 g0             0x0                 0
 g1             0x64                100
 g2             0x1                 1
 g3             0x0                 0
 g4             0xe5ea3b7c          -437634180
 g5             0xe5ed87d4          -437418028
 g6             0x0                 0
 g7             0xe5ea6b58          -437621928
 o0             0x0                 0
 o1             0x344               836
 o2             0xe5e00b48          -438301880
 o3             0x3400              13312
 o4             0xf0b86a30          -256349648
 o5             0x209f0             133616
 sp             0xe7fff458          0xe7fff458
 o7             0x103f8             66552
 l0             0x4400087           71303303
 l1             0xe5e00b48          -438301880
 l2             0xe5e00b4c          -438301876
 l3             0xfc1               4033
 l4             0x1                 1
 l5             0x2                 2
 l6             0xf50d5000          -183676928
 --Type <RET> for more, q to quit, c to continue without paging--
 l7             0xe5ea3b78          -437634184
 i0             0x1                 1
 i1             0xe7fff574          -402655884
 i2             0xe7fff57c          -402655876
 i3             0x1                 1
 i4             0x0                 0
 i5             0xe5ea3b5c          -437634212
 fp             0xe7fff4b8          0xe7fff4b8
 i7             0x106d4             67284
 y              0x0                 0
 psr            0x4400086           [ S ]
 wim            <unavailable>
 tbr            <unavailable>
 pc             0x10748             0x10748 <main+12>
 npc            0x1074c             0x1074c <main+16>
 fsr            0x0                 [ ]
 csr            <unavailable>
 (gdb) p argv[0]
 $1 = 0xe7fffa7c "/home/uwe/hello"


 But then stepping into libc:

 (gdb) s

 Program received signal SIGBUS, Bus error.
 0xe5ed13a4 in _rtld_bind () from /usr/libexec/ld.elf_so
 (gdb)


 -uwe

From: Rin Okuyama <rokuyama.rk@gmail.com>
To: gnats-bugs@netbsd.org, port-sparc-maintainer@netbsd.org,
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, uwe@stderr.spb.ru
Cc: 
Subject: Re: port-sparc/57337: gdb completely broken on sparc
Date: Mon, 4 Sep 2023 18:10:55 +0900

 On 2023/08/29 22:15, Valery Ushakov wrote:
 >   Import of the new gdb seems to have helped somewhat.  I haven't yet
 >   tried any heavy duty debugging, but at least the basics seem to work
 >   again.

 Good to know this!

 >   But then stepping into libc:
 >   
 >   (gdb) s
 >   
 >   Program received signal SIGBUS, Bus error.
 >   0xe5ed13a4 in _rtld_bind () from /usr/libexec/ld.elf_so
 >   (gdb)

 Hmm. It seems like nbsd_skip_resolver() fails for some reasons.
 I will examine later...

 # Another good news for me is recent version of QEMU/sparc works
 # much better than previous versions I remember!

 Thanks,
 rin

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.