From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14732 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Anastasios" Newsgroups: gmane.linux.lib.musl.general Subject: Re: Bug report: strtod drops LSB Date: Wed, 25 Sep 2019 12:56:35 -0500 Message-ID: References: <20190925155151.GV9017@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_20852959.680305262295" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="20094"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mailbird/2.6.1.0 Cc: "" To: "Rich Felker" Original-X-From: musl-return-14748-gllmg-musl=m.gmane.org@lists.openwall.com Wed Sep 25 20:45:54 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iDCIU-00057N-6V for gllmg-musl@m.gmane.org; Wed, 25 Sep 2019 20:45:54 +0200 Original-Received: (qmail 9842 invoked by uid 550); 25 Sep 2019 18:45:51 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 29876 invoked from network); 25 Sep 2019 17:56:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1569434198; bh=Vsk5IttZJM0G0lqbhvZEC5rjMfL3rjyiWMCZYOAUrj0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From:Subject; b=dKE0qAqZeblJ55/RXhfc40eVrY197iiPOthJKq5svsHpdPqtLuhCyDmEuSed95qchORs3Yxxi7bvAHLe2DSf1IyfOq85F0Ta5RrWysnYHmino8ytSw2TSO3jzt7vd9H+gcl/f+itnVVHfFNGryhEjGYq3Rv0qIovfwRn4upE/+r5gli56jYNlGaRFiv5zHgOkF25leO701kItCRWHhbEGJZp6pyu6DX7KoHNZnio0bwb34ZjiyUFvDMrr69Bhtz7szgF5YxFR8/+hP/lFH48jP2io0PvqdMgLGNrX5pt5UsD1yEtq2oFCgrqYIWqtAF36LOt3hbdUkF43WE2yfPdyw== X-YMail-OSG: jgji8xwVM1lBkqu9AEHMSl7tdYF8d7KL7HNyX7Ejdmh1exluXe_QlEF9uYKGG2G 9_whBekc8graMxQ4z5Quo2NoYZRFcx3lPzQvAZVAj_oKBfyDVDPrjmENkvO_grDRspt9BlhhUKwh HGgFdN6RwG7bJrXydzXVYMoPPIaMy98G6nTM_GdPHMjk_kJv0r5_eUOGjhXwZSTbAzUHjnPFx63H uoemU7arz9FUTXcRO4IX6jj4IfdTXm_QzQADVYX8rDWlKX9NFz2NMpbijGzWaDaeBU0I7gcp66qy vOOvhDTe6Z_bW77p.ZMVTs25MCndZ8RV1VSWIQ3DeGrNd2IM9cqkj3uh4ajkI6N.9tylYd.2umUH YDusBbxcuWGjTZpxjsnNxsTs1.Xqg9LrWajO947QJ8Qj0b4KEQeIGyPigGSY802.QubQD2J92Y8s PtcejFajKVh75s0WRTAhVYg14KzRK0UijAEmVKuLIfAHyS81iJz.R_78JrzzcRQ_.IK3Xjb6obfm bqymPdni4dCguW.MmffArY1271cJa79W3gQnDWak9_a4IUPpAcMJgxQKFTpjtFNb_J9Y5915ho83 8fbIlQmP.G0vfFbQTn5.AD5dJoHVDQQqRXMlJETE2iOouQrJTNu1CnCSnvOjb7ef8q7mLrk1zveM SwMBjHKb_JTedQHKCACnkE4rsYSibqEcIMw58NZWdKyHw8u8iL1bIM9CRC8RyDhRbT1Ox.c7z9ps qmLjcUrQ8hc.UwNsv8pK8AAd56ED7wQ40uEzSc5RE4SZTj9bZvTz3HwsKzDFGXdfhdsbdGGelYrM Csa7k_3AZWphu9lfqJaoGPxH38wQq8.nyo0eTdslDN In-Reply-To: <20190925155151.GV9017@brightrain.aerifal.cx> X-Mailbird-ID: ff416ebd-10f5-4e34-b1f3-e6839c6c610d@getmailbird.com Xref: news.gmane.org gmane.linux.lib.musl.general:14732 Archived-At: ------=_NextPart_20852959.680305262295 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Having looked into it more, I found this is due to being on WSL, and it is = a duplicate of=C2=A0https://github.com/microsoft/WSL/issues/830 [https://gi= thub.com/microsoft/WSL/issues/830], which, I see, you are already well awar= e of. Please excuse the noise. On 9/25/2019 10:51:53 AM, Rich Felker wrote: On Wed, Sep 25, 2019 at 09:32:35AM -0500, Anastasios wrote: > Hello, > > Consider this program, strtod.c: > > =C2=A0 =C2=A0=C2=A0#include > =C2=A0 =C2=A0=C2=A0#include > > =C2=A0 =C2=A0=C2=A0int main() > =C2=A0 =C2=A0=C2=A0{ > =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0printf("%lf\n", strtod("28368695230= 6183", NULL)); > =C2=A0 =C2=A0=C2=A0} > > With current musl master from Git: > > =C2=A0 =C2=A0=C2=A0$ musl-gcc -static strtod.c -o a.musl > =C2=A0 =C2=A0 $ ./a.musl > =C2=A0 =C2=A0 283686952306176.000000 > > By comparison, with glibc: > > =C2=A0 =C2=A0 $ gcc -static strtod.c -o a.glibc > =C2=A0 =C2=A0 $ ./a.glibc > =C2=A0 =C2=A0 283686952306183.000000 > > The correct binary representation of this float is > > =C2=A0 =C2=A0 0x42f0203040506070 > > but musl strtod produces > > =C2=A0 =C2=A0 0x42f0203040506000 > > i.e., it fails to set the LSB. I examined this while ruling out printf as= the cause. I can't reproduce this. My test program for strtod shows, for the input "283686952306183": d: 283686952306183 [0x1.020304050607p+48] [42f0203040506070] I suspect you miscompiled musl, possibly by passing in CFLAGS (perhaps from defaults in your environment?) that break floating point semantics. We test for and refuse to build if __FAST_MATH__ is defined, but GCC only defines it if you use -ffast-math, not if you manually enable one or more of the individual broken options that -ffast-math enables. Alternatively, it's possible that you have a broken compiler version that miscompiles floating point code. Rich ------=_NextPart_20852959.680305262295 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Having looked into it more, I found this is due to bein= g on WSL, and it is a duplicate of https://github.com/microsoft/WSL/issues/830, which= , I see, you are already well aware of. Please excuse the noise.=0A

On 9/25/2019 10:51:53 AM, Rich Felker <dalias@libc.org>= ; wrote:

On Wed, S= ep 25, 2019 at 09:32:35AM -0500, Anastasios wrote:=0A
> Hello,=0A
= > =0A
> Consider this program, strtod.c:=0A
> =0A
> &n= bsp;   #include =0A
>     #include= =0A
> =0A
>     int main()=0A
> =     {=0A
>         print= f("%lf\n", strtod("283686952306183", NULL));=0A
>     = }=0A
> =0A
> With current musl master from Git:=0A
> =0A<= br>>     $ musl-gcc -static strtod.c -o a.musl=0A
>=     $ ./a.musl=0A
>     283686952306176.000000= =0A
> =0A
> By comparison, with glibc:=0A
> =0A
> &= nbsp;   $ gcc -static strtod.c -o a.glibc=0A
>     $ .= /a.glibc=0A
>     283686952306183.000000=0A
> =0A
= > The correct binary representation of this float is=0A
> =0A
&= gt;     0x42f0203040506070=0A
> =0A
> but musl strtod= produces=0A
> =0A
>     0x42f0203040506000=0A
>= ; =0A
> i.e., it fails to set the LSB. I examined this while ruling o= ut printf as the cause.=0A
=0A
I can't reproduce this. My test progra= m for strtod shows, for the=0A
input "283686952306183":=0A
=0A
d: = 283686952306183 [0x1.020304050607p+48] [42f0203040506070]=0A
=0A
I s= uspect you miscompiled musl, possibly by passing in CFLAGS (perhaps=0A
f= rom defaults in your environment?) that break floating point=0A
semantic= s. We test for and refuse to build if __FAST_MATH__ is=0A
defined, but G= CC only defines it if you use -ffast-math, not if you=0A
manually enable= one or more of the individual broken options that=0A
-ffast-math enable= s.=0A
=0A
Alternatively, it's possible that you have a broken compile= r version=0A
that miscompiles floating point code.=0A
=0A
Rich=0A<= br>
------=_NextPart_20852959.680305262295--