NetBSD Problem Report #55668

From martin@aprisoft.de  Thu Sep 17 19:28:43 2020
Return-Path: <martin@aprisoft.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 53BBB1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 17 Sep 2020 19:28:43 +0000 (UTC)
Message-Id: <20200917192833.D8A045CC7A1@emmas.aprisoft.de>
Date: Thu, 17 Sep 2020 21:28:33 +0200 (CEST)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: can not build current on current
X-Send-Pr-Version: 3.95

>Number:         55668
>Category:       toolchain
>Synopsis:       can not build current on current
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 17 19:30:00 +0000 2020
>Closed-Date:    Fri Aug 11 06:10:32 +0000 2023
>Last-Modified:  Fri Aug 11 06:10:32 +0000 2023
>Originator:     Martin Husemann
>Release:        NetBSD 9.99.73
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD seven-days-to-the-wolves.aprisoft.de 9.99.73 NetBSD 9.99.73 (GENERIC) #418: Thu Sep 17 13:45:44 CEST 2020 martin@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

On a -current machine with all gcc 9 userland I can not build
-current for evbearmv5 with HAVE_GCC=8 (not sure if the latter
part is relevant).

The build "hangs" with a bunch of nbawk busy looping processes,
called for processing some objdump output (or so it seems).
I see several instances like this:

10715 pts/0 I+    0:00.00 | |           |                       |-- sh 
20776 pts/0 S+    0:00.04 | |           |                       | `-- /work/tools/bin/nbmake _THISDIR_ dependall 
26763 pts/0 I+    0:00.00 | |           |                       |   `-- sh 
25218 pts/0 S+    0:00.04 | |           |                       |     `-- /work/tools/bin/nbmake realall 
 1673 pts/0 I+    0:00.00 | |           |                       |       `-- sh 
27693 pts/0 I+    0:00.00 | |           |                       |         `-- sh 
15262 pts/0 R+   40:22.41 | |           |                       |           |-- /work/tools/bin/nbawk -f /work/tools/bin/nbawk 
19130 pts/0 I+    0:00.00 | |           |                       |           `-- /work/tools/bin/arm--netbsdelf-eabi-objdump --syms --reloc tmp.o (arm--netbsdelf-e)
19002 pts/0 I+    0:00.00 | |           |                       |-- sh 
[..]

and this stays the same for hours (lost patience and kille the build).

>How-To-Repeat:
s/a

>Fix:
n/a

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@homeworld.netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/55668: can not build current on current
Date: Fri, 18 Sep 2020 11:33:03 +0000

 The awk hangs here:

 #2  0x0000786f9a3482bf in _int_strtod_l (s00=<optimized out>, 
     se=0x7f7fff63f210, loc=<optimized out>)
     at /work/src/lib/libc/gdtoa/strtod.c:677
 #3  0x000000000040c733 in get_number (
     s=0x786f9b425000 "0002e308 R_ARM_ABS32       .debug_str", 
     res=0x786f9b1f5018)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:763
 #4  0x000000000040c7f8 in check_number (x=0x786f9b1f5000)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:777
 #5  0x000000000040a7d5 in getrec (pbuf=0x634698 <record>, 
     pbufsize=0x633548 <recsize>, isrecord=true)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:194
 #6  0x000000000040dcc4 in program (a=0x786f9b1ea528, n=258)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:199
 #7  0x000000000040db1f in execute (u=0x786f9b1ea510)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:168
 #8  0x000000000040da02 in run (a=0x786f9b1ea510)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:143
 #9  0x000000000040cefb in main (argc=1, argv=0x7f7fff63f3e8)


 or here:

 #0  __lshift_D2A (b=0x70c9805fdd60, k=23)
     at /work/src/lib/libc/gdtoa/misc.c:495
 #1  0x000070c980348505 in _int_strtod_l (s00=<optimized out>, 
     se=0x7f7fff0f2c90, loc=<optimized out>)
     at /work/src/lib/libc/gdtoa/strtod.c:662
 #2  0x000000000040c733 in get_number (
     s=0x70c9814cb000 "0002e308 R_ARM_CALL        printf", res=0x70c98149e018)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:763
 #3  0x000000000040c7f8 in check_number (x=0x70c98149e000)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:777
 #4  0x000000000040a7d5 in getrec (pbuf=0x634698 <record>, 
     pbufsize=0x633548 <recsize>, isrecord=true)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:194
 #5  0x000000000040dcc4 in program (a=0x70c98148d528, n=258)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:199
 #6  0x000000000040db1f in execute (u=0x70c98148d510)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:168
 #7  0x000000000040da02 in run (a=0x70c98148d510)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:143
 #8  0x000000000040cefb in main (argc=1, argv=0x7f7fff0f2e68)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/main.c:229

 or

 #0  __Bfree_D2A (v=0x7c27daffe2c0) at /work/src/lib/libc/gdtoa/misc.c:107
 #1  0x00007c27dad483d8 in _int_strtod_l (s00=<optimized out>, 
     se=0x7f7fff2128a0, loc=<optimized out>)
     at /work/src/lib/libc/gdtoa/strtod.c:1055
 #2  0x000000000040c733 in get_number (
     s=0x7c27dbfaf000 "0002e308 R_ARM_ABS32       .debug_str", 
     res=0x7c27dbf82018)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:763
 #3  0x000000000040c7f8 in check_number (x=0x7c27dbf82000)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:777
 #4  0x000000000040a7d5 in getrec (pbuf=0x634698 <record>, 
     pbufsize=0x633548 <recsize>, isrecord=true)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:194
 #5  0x000000000040dcc4 in program (a=0x7c27dbf774c8, n=258)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:199
 #6  0x000000000040db1f in execute (u=0x7c27dbf774b0)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:168
 #7  0x000000000040da02 in run (a=0x7c27dbf774b0)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:143
 #8  0x000000000040cefb in main (argc=1, argv=0x7f7fff212a78)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/main.c:229

 or

 #0  0x000079e688571ea2 in __d2b_D2A (dd=<optimized out>, 
     e=e@entry=0x7f7fff545b98, bits=bits@entry=0x7f7fff545ba0)
     at /work/src/lib/libc/gdtoa/misc.c:849
 #1  0x000079e688548426 in _int_strtod_l (s00=<optimized out>, 
     se=0x7f7fff545c10, loc=<optimized out>)
     at /work/src/lib/libc/gdtoa/strtod.c:584
 #2  0x000000000040c733 in get_number (
     s=0x79e689636000 "0002e308 R_ARM_ABS32       .debug_str", 
     res=0x79e689609018)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:763
 #3  0x000000000040c7f8 in check_number (x=0x79e689609000)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:777
 #4  0x000000000040a7d5 in getrec (pbuf=0x634698 <record>, 
     pbufsize=0x633548 <recsize>, isrecord=true)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:194
 #5  0x000000000040dcc4 in program (a=0x79e689605528, n=258)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:199
 #6  0x000000000040db1f in execute (u=0x79e689605510)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:168
 #7  0x000000000040da02 in run (a=0x79e689605510)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:143
 #8  0x000000000040cefb in main (argc=1, argv=0x7f7fff545de8)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/main.c:229

 or

 #0  __mult_D2A (a=0x7549079fe220, a@entry=0x7549079fdcd0, b=<optimized out>, 
     b@entry=0x7549079fe220) at /work/src/lib/libc/gdtoa/misc.c:330
 #1  0x00007549077718a6 in __pow5mult_D2A (b=0x7549079fdcd0, 
     b@entry=0x7549079fdc60, k=1, k@entry=308)
     at /work/src/lib/libc/gdtoa/misc.c:436
 #2  0x000075490774859d in _int_strtod_l (s00=<optimized out>, 
     se=0x7f7fff4486a0, loc=<optimized out>)
     at /work/src/lib/libc/gdtoa/strtod.c:667
 #3  0x000000000040c733 in get_number (
     s=0x754908837000 "0003e308 R_ARM_ABS32       .debug_str", 
     res=0x75490880a018)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:763
 #4  0x000000000040c7f8 in check_number (x=0x75490880a000)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:777
 #5  0x000000000040a7d5 in getrec (pbuf=0x634698 <record>, 
     pbufsize=0x633548 <recsize>, isrecord=true)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/lib.c:194
 #6  0x000000000040dcc4 in program (a=0x7549085fc4c8, n=258)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:199
 #7  0x000000000040db1f in execute (u=0x7549085fc4b0)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:168
 #8  0x000000000040da02 in run (a=0x7549085fc4b0)
     at /work/src/tools/awk/../../external/historical/nawk/bin/../dist/run.c:143

 This is totally reproducable.

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/55668: can not build current on current
Date: Fri, 18 Sep 2020 14:26:06 +0200

 This is trivially reproducable by the test below.

 Just do: 

 cc -Wall -O2 test.c
 ./a.out

 and watch it hang.

 Martin


 --8<--
 #include <stdio.h>
 #include <stdlib.h>

 int main(int argc, char **argv)
 {
         double r;
         char *ep;
         char inp[] = "0002e308 R_ARM_ABS32       .debug_str";

         r = strtod(inp, &ep);
         printf("r: %.6f, ep: %s\n", r, ep);
         return 0;
 }

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/55668: can not build current on current
Date: Fri, 18 Sep 2020 14:48:08 +0200

 The test case busy loops on sparc64 too, it seems to do an endless loop

 It runs into an endless loop here:

 958                     /* Check for overflow */
 959     
 960                     if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
 961                             dval(&rv0) = dval(&rv);
 962                             word0(&rv) -= P*Exp_msk1;
 963                             dval(&adj) = dval(&aadj1) * ulp(&rv);
 964                             dval(&rv) += dval(&adj);
 965                             if ((word0(&rv) & Exp_mask) >=
 966                                             Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
 967                                     if (word0(&rv0) == Big0 && word1(&rv0) == Big1)
 968                                             goto ovfl;
 969                                     word0(&rv) = Big0;
 970                                     word1(&rv) = Big1;
 971                                     goto cont;
 972                                     }

 Note that the whole loop only seems to modify rv, but the test in line 967
 checks rv0 - copy & pasto?

 Martin

From: Jason Thorpe <thorpej@me.com>
To: gnats-bugs@netbsd.org
Cc: toolchain-manager@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 "martin@netbsd.org" <martin@NetBSD.org>
Subject: Re: toolchain/55668: can not build current on current
Date: Fri, 18 Sep 2020 06:15:57 -0700

 > On Sep 18, 2020, at 5:50 AM, Martin Husemann <martin@duskware.de> =
 wrote:
 >=20
 > 961                             dval(&rv0) =3D dval(&rv);
 >=20
 > Note that the whole loop only seems to modify rv, but the test in line =
 967
 > checks rv0 - copy & pasto?

 Isn't rv0 modified on line 961?  I don't really see anything obviously =
 wrong with that block of code.

 -- thorpej

From: Martin Husemann <martin@duskware.de>
To: Jason Thorpe <thorpej@me.com>
Cc: gnats-bugs@netbsd.org
Subject: Re: toolchain/55668: can not build current on current
Date: Fri, 18 Sep 2020 15:20:57 +0200

 On Fri, Sep 18, 2020 at 06:15:57AM -0700, Jason Thorpe wrote:
 > Isn't rv0 modified on line 961?  I don't really see anything obviously wrong with that block of code.

 Yeah, but stepping in gdb does not hit that line (and this failure only
 started with the switch to gcc 9)

 Martin

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55668 CVS commit: src/lib/libc/gdtoa
Date: Fri, 18 Sep 2020 10:06:46 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Fri Sep 18 14:06:45 UTC 2020

 Modified Files:
 	src/lib/libc/gdtoa: strtod.c

 Log Message:
 PR/55668: Martin Husemann: Disable optimization to avoid infinite loop.
 Also bring in a few changes from the most recent gdtoa code (not relevant
 to the bug).


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 src/lib/libc/gdtoa/strtod.c

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

From: "matthew green" <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55668 CVS commit: src/external/gpl3/gcc
Date: Fri, 11 Aug 2023 05:34:36 +0000

 Module Name:	src
 Committed By:	mrg
 Date:		Fri Aug 11 05:34:36 UTC 2023

 Modified Files:
 	src/external/gpl3/gcc: README.gcc12

 Log Message:
 the sh3 build issue is related to a forced -O0 in strtod.c and PR#55668.

 initial tests show it doesn't fail with gcc 10 or 12 (but building with
 gcc9 to test there now to be sure.)


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 src/external/gpl3/gcc/README.gcc12

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

From: "matthew green" <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55668 CVS commit: src/lib/libc/gdtoa
Date: Fri, 11 Aug 2023 06:02:46 +0000

 Module Name:	src
 Committed By:	mrg
 Date:		Fri Aug 11 06:02:46 UTC 2023

 Modified Files:
 	src/lib/libc/gdtoa: strtod.c

 Log Message:
 remove the -O0 force for _int_strtod_l() and GCC 9, it's fixed in GCC 10 and 12.

 this was triggering sh3 GCC 12 to fail compiles because of ssp.h's memcpy()
 frontend having the always_inline attribute that didn't match -O0 or so.

 tested with pkgsrc gcc9 to confirm it hangs there, but newer versions are fine.

 also known as PR#55668, which now has a real fix (gcc 10 :-).


 To generate a diff of this commit:
 cvs rdiff -u -r1.18 -r1.19 src/lib/libc/gdtoa/strtod.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->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Fri, 11 Aug 2023 06:10:32 +0000
State-Changed-Why:
bug was actually fixed with GCC 10 import a while ago.  the workaround
has been backed out and could perhaps be pulled up to netbsd-10.


>Unformatted:

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.