NetBSD Problem Report #44389

From www@NetBSD.org  Fri Jan 14 17:41:09 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 1D8B963B9AF
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 14 Jan 2011 17:41:09 +0000 (UTC)
Message-Id: <20110114174108.82D7363B966@www.NetBSD.org>
Date: Fri, 14 Jan 2011 17:41:08 +0000 (UTC)
From: mateusz@loskot.net
Reply-To: mateusz@loskot.net
To: gnats-bugs@NetBSD.org
Subject: awk failure during m4 installation with pkgsrc
X-Send-Pr-Version: www-1.0

>Number:         44389
>Category:       port-sparc
>Synopsis:       awk failure during m4 installation with pkgsrc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 14 17:45:00 +0000 2011
>Closed-Date:    Sun Jan 23 02:28:26 +0000 2011
>Last-Modified:  Sun Jan 23 02:28:26 +0000 2011
>Originator:     Mateusz Loskot
>Release:        5.1
>Organization:
>Environment:
NetBSD qemu-netbsd-51-sparc 5.1 NetBSD 5.1 (GENERIC) #0: Sat Nov  6 18:44:40 UTC 2010  builds@b6.netbsd.org:/home/builds/ab/netbsd-5-1-RELEASE/sparc/201011061943Z-obj/home/builds/ab/netbsd-5-1-RELEASE/src/sys/arch/sparc/compile/GENERIC sparc
>Description:
Installation of m4-1.4.15 package using pkgsrc fails with floating point exception. Here is the full command output:

qemu-netbsd-51-sparc# make install clean
qemu-netbsd-51-sparc# pwd
/usr/pkgsrc/devel/m4
qemu-netbsd-51-sparc# make install clean
=> Bootstrap dependency digest>=20010302: found digest-20080510
===> Checking for vulnerabilities in m4-1.4.15
===> Configuring for m4-1.4.15
=> Modifying GNU configure scripts to avoid --recheck
/usr/bin/awk: floating point exception 8
 input record number 18792, file configure
 source line number 1
*** Error code 2

Stop.
make: stopped in /usr/pkgsrc/devel/m4
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/devel/m4
qemu-netbsd-51-sparc#

Folks on #netbsd IRC channel suggested it may be related to SPARC architecture.

>How-To-Repeat:
On NetBSD5 5.1/SPARC issue:

# cd /usr/pkgsrc/devel/m4
# make install clean
>Fix:

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
Date: Fri, 14 Jan 2011 20:43:44 +0100

 On Fri, Jan 14, 2011 at 05:45:01PM +0000, mateusz@loskot.net wrote:
 > /usr/bin/awk: floating point exception 8
 >  input record number 18792, file configure
 >  source line number 1
 > *** Error code 2

 My bet would be a qemu bug.

 Martin

From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: Martin Husemann <martin@duskware.de>, 
 port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org, 
 netbsd-bugs@netbsd.org
Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
Date: Fri, 14 Jan 2011 21:14:59 +0000

 On 14/01/11 19:45, Martin Husemann wrote:
 > The following reply was made to PR port-sparc/44389; it has been noted by GNATS.
 > 
 > From: Martin Husemann <martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org,
 > 	netbsd-bugs@netbsd.org
 > Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
 > Date: Fri, 14 Jan 2011 20:43:44 +0100
 > 
 >  On Fri, Jan 14, 2011 at 05:45:01PM +0000, mateusz@loskot.net wrote:
 >  > /usr/bin/awk: floating point exception 8
 >  >  input record number 18792, file configure
 >  >  source line number 1
 >  > *** Error code 2
 >  
 >  My bet would be a qemu bug.

 Could you suggest how to isolate the problem, find exact awk command
 causing the error, so I can debug it or forward to QEMU developers with
 details necessary to reproduce it?


 I'd like to try to investigate it myself as far as I can, but I'm not
 very experienced with NetBSD neither with pkgsrc.

 I guess the pkgsrc output is not enough proof to assume this is QEMU issue.

 Mateusz

 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: martin@duskware.de, tsutsui@ceres.dti.ne.jp
Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
Date: Sat, 15 Jan 2011 10:49:40 +0900

 > >  > /usr/bin/awk: floating point exception 8
 > >  >  input record number 18792, file configure
 > >  >  source line number 1
 > >  > *** Error code 2
 > >  
 > >  My bet would be a qemu bug.
 > 
 > Could you suggest how to isolate the problem,

 It just works on a real SS20. Isn't it enough to say it's a qemu bug? 
 ---
  :
 ===> Overriding tools for m4-1.4.15
 ===> Extracting for m4-1.4.15
 ===> Patching for m4-1.4.15
 => Applying pkgsrc patches for m4-1.4.15
 ===> Creating toolchain wrappers for m4-1.4.15
 ===> Configuring for m4-1.4.15
 => Modifying GNU configure scripts to avoid --recheck
 => Replacing config-guess with pkgsrc versions
 => Replacing config-sub with pkgsrc versions
 => Replacing install-sh with pkgsrc version
 checking for a BSD-compatible install... /usr/bin/install -c -o root -g wheel
 checking whether build environment is sane... yes
 checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
 checking for gawk... /usr/bin/awk
 checking whether make sets $(MAKE)... yes
 checking for sparc--netbsdelf-gcc... cc
  :
 ---

 > find exact awk command
 > causing the error, so I can debug it or forward to QEMU developers with
 > details necessary to reproduce it?

 Probably you can mention what you did (including how to fetch pkgsrc)
 in a bug report to qemu?
 ---
 Izumi Tsutsui

From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, 
 port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org, 
 netbsd-bugs@netbsd.org
Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
Date: Sat, 15 Jan 2011 17:19:28 +0000

 On 15/01/11 01:50, Izumi Tsutsui wrote:
 > The following reply was made to PR port-sparc/44389; it has been noted by GNATS.
 > 
 > From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
 > To: gnats-bugs@NetBSD.org
 > Cc: martin@duskware.de, tsutsui@ceres.dti.ne.jp
 > Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
 > Date: Sat, 15 Jan 2011 10:49:40 +0900
 > 
 >  > >  > /usr/bin/awk: floating point exception 8
 >  > >  >  input record number 18792, file configure
 >  > >  >  source line number 1
 >  > >  > *** Error code 2
 >  > >  
 >  > >  My bet would be a qemu bug.
 >  > 
 >  > Could you suggest how to isolate the problem,
 >  
 >  It just works on a real SS20.

 I see.

 > Isn't it enough to say it's a qemu bug?

 I believe it is not.
 The error I've reported is thrown by AWK called from deep abbys of
 pkgsrc. AWK sits on the execution stack high above any hardware (even
 emulated), so I can't really think of debugging emulator
 without exact command AWK was executed, at least.

 Is it possible to trace pkgsrc and find where AWK is called from
 and find exact AWK command executed?

 >  ---
 >   :
 >  ===> Overriding tools for m4-1.4.15
 >  ===> Extracting for m4-1.4.15
 >  ===> Patching for m4-1.4.15
 >  => Applying pkgsrc patches for m4-1.4.15
 >  ===> Creating toolchain wrappers for m4-1.4.15
 >  ===> Configuring for m4-1.4.15
 >  => Modifying GNU configure scripts to avoid --recheck
 >  => Replacing config-guess with pkgsrc versions
 >  => Replacing config-sub with pkgsrc versions
 >  => Replacing install-sh with pkgsrc version
 >  checking for a BSD-compatible install... /usr/bin/install -c -o root -g wheel
 >  checking whether build environment is sane... yes
 >  checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
 >  checking for gawk... /usr/bin/awk
 >  checking whether make sets $(MAKE)... yes
 >  checking for sparc--netbsdelf-gcc... cc
 >   :
 >  ---
 >  
 >  > find exact awk command
 >  > causing the error, so I can debug it or forward to QEMU developers with
 >  > details necessary to reproduce it?
 >  
 >  Probably you can mention what you did (including how to fetch pkgsrc)
 >  in a bug report to qemu?

 I have forwarded the whole story to the QEMU team:

 http://lists.nongnu.org/archive/html/qemu-devel/2011-01/msg01509.html

 However, a reproducible test case is essential and I'm not surprised.

 Best regards,
 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Martin Husemann <martin@duskware.de>
To: Mateusz Loskot <mateusz@loskot.net>
Cc: gnats-bugs@NetBSD.org, Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>,
	port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
Date: Sat, 15 Jan 2011 18:26:03 +0100

 On Sat, Jan 15, 2011 at 05:19:28PM +0000, Mateusz Loskot wrote:
 > Is it possible to trace pkgsrc and find where AWK is called from
 > and find exact AWK command executed?

 ktrace -i the make and check the output of kdump.

 Martin

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: port-sparc/44389: awk failure during m4 installation with pkgsrc
Date: Sun, 16 Jan 2011 02:51:38 +0900

 > Is it possible to trace pkgsrc and find where AWK is called from
 > and find exact AWK command executed?

 Probably you should ask it on pkgsrc lists, not in PR of port-sparc.
 ---
 Izumi Tsutsui

From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 11:35:44 +0000

 I have managed to isolate exact command causing the problem.

 So, I am trying to install m4 using pkgsrc on NetBSD 5.1/SPARC and with 
 higher debug level, I can trace what is happening:

 #################################################################
 # cd /usr/pkgsrc/devel/m4
 # make PKG_DEBUG_LEVEL=2
 ...
 ===> Configuring for m4-1.4.15
 => Modifying GNU configure scripts to avoid --recheck
 : commands for target configure-scripts-override; set -x; set -e;  cd 
 /usr/pkgsrc_work/devel/m4/work/m4-1.4.15; 
                     depth=0; pattern=configure; 
      while test $depth -le 2; do     for file in $pattern; do 
                       test -f "$file" || continue; 
 /usr/bin/awk '/ *-recheck *\| *--recheck.*\)/ { 
 print;                                          print "        : Avoid 
 regenerating within pkgsrc";     print "        exit 0"; 
                   next;                                           } 
                                                    { print }' $file > 
 $file.override;                      /bin/chmod +x $file.override; 
                               /bin/mv -f $file.override $file; 
                        done; 
         depth=`/bin/expr $depth + 1`; pattern="*/$pattern";     done
 + set -e
 + cd /usr/pkgsrc_work/devel/m4/work/m4-1.4.15
 + depth=0
 + pattern=configure
 + test 0 -le 2
 + test -f configure
 + /usr/bin/awk / *-recheck *\| *--recheck.*\)/ { 
   print;                                          print "        : Avoid 
 regenerating within pkgsrc";     print "        exit 0"; 
                   next;                                           } 
                                                    { print } configure
 /usr/bin/awk: floating point exception 8
   input record number 18792, file configure
   source line number 1
 *** Error code 2

 Stop.
 make: stopped in /usr/pkgsrc/devel/m4
 #################################################################


 Context of the line 18792 in m4 ./configure script is:


 static float
 NaN ()
 {
    static float zero = 0.0f;
    return zero / zero;
 }


 and AWK is throwing error parsing the "Nan ()" line:


 #  echo "NaN ()" | /usr/bin/awk '/ *-recheck *\| *--recheck.*\)/ { print; }'
 /usr/bin/awk: floating point exception 8
   source line number 1


 Eventually, the failing command boils down to this simple form:


 # echo NaN | awk '{print "test"}'
 awk: floating point exception 8
   source line number 1


 Obviously, changing NaN to something else makes it working:


 # echo xNaN | awk '{print "test"}'
 test


 The problem seems to be with AWK on NetBSD 5.1/SPARC which
 interprets "NaN" as a number when it isn't asked to.

 Just to remind, I'm running the system under QEMU and I believe
 this issue is not related to QEMU like it was suggested.

 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: mateusz@loskot.net
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 12:49:12 +0100

 On Tue, Jan 18, 2011 at 11:35:01AM +0000, Mateusz Loskot wrote:
 >  Just to remind, I'm running the system under QEMU and I believe
 >  this issue is not related to QEMU like it was suggested.

 Maybe it is instead related to your local environment?
 Are you sure you are using the NetBSD in-tree /usr/bin/awk, unmodified?

 Martin

From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 12:02:31 +0000

 On 18/01/11 11:50, Martin Husemann wrote:
 > From: Martin Husemann<martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: mateusz@loskot.net
 > Subject: Re: port-sparc/44389
 > Date: Tue, 18 Jan 2011 12:49:12 +0100
 >
 >   On Tue, Jan 18, 2011 at 11:35:01AM +0000, Mateusz Loskot wrote:
 >   >   Just to remind, I'm running the system under QEMU and I believe
 >   >   this issue is not related to QEMU like it was suggested.
 >
 >   Maybe it is instead related to your local environment?
 >   Are you sure you are using the NetBSD in-tree /usr/bin/awk, unmodified?
 >
 >   Martin

 Yes, I am sure:

 qemu-netbsd-51-sparc$ which awk
 /usr/bin/awk

 Simply, I have installed NetBSD 5.1 on SPARC using sparccd.iso
 and got AWK installed this way.
 Then I grabbed current pkgsrc and started installing
 Automake, Autoconf, m4, etc.

 I have not tweaked anything in any custom way.

 -- 
 Mateusz Loskot, http://mateusz.loskot.net

From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 12:17:12 +0000

 Hi,

 >  I have managed to isolate exact command causing the problem.
 >  
 >  So, I am trying to install m4 using pkgsrc on NetBSD 5.1/SPARC and with 
 >  higher debug level, I can trace what is happening:

 >  + /usr/bin/awk / *-recheck *\| *--recheck.*\)/ { 
 >    print;                                          print "        : Avoid 
 >  regenerating within pkgsrc";     print "        exit 0"; 
 >                    next;                                           } 
 >                                                     { print } configure

 >  Context of the line 18792 in m4 ./configure script is:

 >  static float
 >  NaN ()
 >  {
 >     static float zero = 0.0f;
 >     return zero / zero;
 >  }

 >  and AWK is throwing error parsing the "Nan ()" line:

 >  #  echo "NaN ()" | /usr/bin/awk '/ *-recheck *\| *--recheck.*\)/ { print; }'
 >  /usr/bin/awk: floating point exception 8
 >    source line number 1

 >  Eventually, the failing command boils down to this simple form:

 >  # echo NaN | awk '{print "test"}'
 >  awk: floating point exception 8
 >    source line number 1

 >  Just to remind, I'm running the system under QEMU and I believe
 >  this issue is not related to QEMU like it was suggested.

 I have run all the above commands on a sparc (SS20) running 5.0_STABLE (which
 has the same awk version as 5.1:

   $ awk --version
   awk version 20070501

 ) and I get no crashes with awk.

 Thanks,

 J

 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: mateusz@loskot.net
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 13:18:04 +0100

 What type of cpu is qemu emulationg? Can you show the output of

  dmesg | egrep ^cpu

 and 

  sysctl machdep

 please?

 Thanks,

 Martin

From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 12:35:16 +0000

 On 18/01/11 12:18, Martin Husemann wrote:
 > What type of cpu is qemu emulationg? Can you show the output of
 >
 >   dmesg | egrep ^cpu


 $ dmesg | egrep ^cpu
 cpu0 at mainbus0: MB86907 @ 170 MHz, L64804 FPU
 cpu0: 16K instruction (32 b/l), 8K data (16 b/l), 512K external (32 
 b/l): cache enabled


 >   sysctl machdep

 $ sysctl machdep
 machdep.booted_kernel = netbsd
 machdep.booted_device = /iommu/sbus/espdma/esp/sd@0,0
 machdep.cpu_arch = 8

 and a bit more details:

 $ sysctl -a | egrep -i 'hw.machine|hw.model|hw.ncpu'
 hw.machine = sparc
 hw.model = SUNW,SPARCstation-5 (MB86907 @ 170 MHz, L64804 FPU)
 hw.ncpu = 1
 hw.machine_arch = sparc
 hw.ncpuonline = 1

 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Antti Kantee <pooka@cs.hut.fi>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 14:43:00 +0200

 Just as a friendly reminder, everyone can produce a NetBSD 5.1 sparc/qemu
 image with:

 anita interact http://ftp.netbsd.org/pub/NetBSD/NetBSD-5.1/iso/sparccd-5.1.iso

 I can repeat the "echo NaN()" problem on an installation produced by
 the above command.

From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: Antti Kantee <pooka@cs.hut.fi>, port-sparc-maintainer@netbsd.org, 
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 12:53:59 +0000

 On 18/01/11 12:45, Antti Kantee wrote:
 > The following reply was made to PR port-sparc/44389; it has been noted by GNATS.
 >
 > From: Antti Kantee<pooka@cs.hut.fi>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: port-sparc/44389
 > Date: Tue, 18 Jan 2011 14:43:00 +0200
 >
 >   Just as a friendly reminder, everyone can produce a NetBSD 5.1 sparc/qemu
 >   image with:
 >
 >   anita interact http://ftp.netbsd.org/pub/NetBSD/NetBSD-5.1/iso/sparccd-5.1.iso

 Here are my images:

 http://mateusz.loskot.net/tmp/qemu/

 and netbsd-5.1-sparccd.img is the one which can be
 used to reproduce the problem. Load this way:

 qemu-system-sparc -m 256 -hda netbsd-5.1-sparccd.img

 >   I can repeat the "echo NaN()" problem on an installation produced by
 >   the above command.

 Good to know.

 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: mateusz@loskot.net
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 14:02:45 +0100

 Could you try compiling and running this simple test program?

 #include <stdlib.h>

 int main(int argc, char **argv)
 {
         char *endp;
         double d = strtod("NaN", &endp);
         return 0;
 }


 This should output nothing - if it gets a fpu exception, pass it to the
 qemu maintainers.

 Martin

From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: Martin Husemann <martin@duskware.de>, 
 port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org, 
 netbsd-bugs@netbsd.org
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 13:21:43 +0000

 On 18/01/11 13:05, Martin Husemann wrote:
 > The following reply was made to PR port-sparc/44389; it has been noted by GNATS.
 >
 > From: Martin Husemann<martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: mateusz@loskot.net
 > Subject: Re: port-sparc/44389
 > Date: Tue, 18 Jan 2011 14:02:45 +0100
 >
 >   Could you try compiling and running this simple test program?
 >
 >   #include<stdlib.h>
 >
 >   int main(int argc, char **argv)
 >   {
 >           char *endp;
 >           double d = strtod("NaN",&endp);
 >           return 0;
 >   }
 >
 >
 >   This should output nothing - if it gets a fpu exception, pass it to the
 >   qemu maintainers.


 Here it is:

 qemu-netbsd-51-sparc$ gcc ./nan_test.c
 qemu-netbsd-51-sparc$ ./a.out
 qemu-netbsd-51-sparc$


 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 14:30:09 +0100

 Ok - last try - check the output of this one.

 Martin

 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
 #include <errno.h>

 int is_number(const char *s)
 {
 	double r;
 	char *ep;
 	errno = 0;
 	r = strtod(s, &ep);
 	if (ep == s || r == HUGE_VAL || errno == ERANGE)
 		return 0;
 	while (*ep == ' ' || *ep == '\t' || *ep == '\n')
 		ep++;
 	if (*ep == '\0')
 		return 1;
 	else
 		return 0;
 }

 int main(int argc, char **argv)
 {
 	double v;

 	if (is_number("NaN")) {
 		printf("is a number\n");
 		v = atof("NaN");
 	} else {
 		printf("not a number\n");
 		v = 0.0;
 	}
 	printf("%.4f\n", v);

 	return 0;
 }


From: Mateusz Loskot <mateusz@loskot.net>
To: gnats-bugs@NetBSD.org
Cc: Martin Husemann <martin@duskware.de>, 
 port-sparc-maintainer@netbsd.org, gnats-admin@netbsd.org, 
 netbsd-bugs@netbsd.org
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 15:00:42 +0000

 On 18/01/11 13:35, Martin Husemann wrote:
 > The following reply was made to PR port-sparc/44389; it has been noted by GNATS.
 >
 > From: Martin Husemann<martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: port-sparc/44389
 > Date: Tue, 18 Jan 2011 14:30:09 +0100
 >
 >   Ok - last try - check the output of this one.
 >
 >   Martin
 >
 >   #include<stdio.h>
 >   #include<stdlib.h>
 >   #include<math.h>
 >   #include<errno.h>
 >
 >   int is_number(const char *s)
 >   {
 >   	double r;
 >   	char *ep;
 >   	errno = 0;
 >   	r = strtod(s,&ep);
 >   	if (ep == s || r == HUGE_VAL || errno == ERANGE)
 >   		return 0;
 >   	while (*ep == ' ' || *ep == '\t' || *ep == '\n')
 >   		ep++;
 >   	if (*ep == '\0')
 >   		return 1;
 >   	else
 >   		return 0;
 >   }
 >
 >   int main(int argc, char **argv)
 >   {
 >   	double v;
 >
 >   	if (is_number("NaN")) {
 >   		printf("is a number\n");
 >   		v = atof("NaN");
 >   	} else {
 >   		printf("not a number\n");
 >   		v = 0.0;
 >   	}
 >   	printf("%.4f\n", v);
 >
 >   	return 0;
 >   }


 This one receive SIGFPE:

 $ gcc ./nan_test_2.c
 $ ./a.out
 [1]   Floating point exception (core dumped) ./a.out

 Specifically, it's caused by r == HUGE_VAL condition in
 if (ep == s || r == HUGE_VAL || errno == ERANGE)

 Though, not sure about conclusion.

 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Martin Husemann <martin@duskware.de>
To: Mateusz Loskot <mateusz@loskot.net>
Cc: gnats-bugs@NetBSD.org
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 16:06:38 +0100

 On Tue, Jan 18, 2011 at 03:00:42PM +0000, Mateusz Loskot wrote:
 > Specifically, it's caused by r == HUGE_VAL condition in
 > if (ep == s || r == HUGE_VAL || errno == ERANGE)
 > 
 > Though, not sure about conclusion.

 Bug in qemu, pass the test program upstream.

 Martin

From: Mateusz Loskot <mateusz@loskot.net>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@NetBSD.org
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 15:12:22 +0000

 On 18/01/11 15:06, Martin Husemann wrote:
 > On Tue, Jan 18, 2011 at 03:00:42PM +0000, Mateusz Loskot wrote:
 >> Specifically, it's caused by r == HUGE_VAL condition in
 >> if (ep == s || r == HUGE_VAL || errno == ERANGE)
 >>
 >> Though, not sure about conclusion.
 >
 > Bug in qemu, pass the test program upstream.

 Martin,

 I will.

 Thank you very much for your help.

 -- 
 Mateusz Loskot, http://mateusz.loskot.net
 Charter Member of OSGeo, http://osgeo.org
 Member of ACCU, http://accu.org

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: mateusz@loskot.net
Subject: Re: port-sparc/44389
Date: Tue, 18 Jan 2011 16:12:55 +0100

 Thanks for narrowing it down that much!

 For the qemu maintainers it would probably be helpfull if you could
 minimize the test case even more, then test with a version comiled with
 -static and objdump -d the binary.

 Martin

State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 23 Jan 2011 11:28:26 +0900
State-Changed-Why:
Qemu bug.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.