From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12699 Path: news.gmane.org!.POSTED!not-for-mail From: "dgutson ." Newsgroups: gmane.linux.lib.musl.general Subject: Re: catan errors Date: Tue, 10 Apr 2018 18:27:24 -0300 Message-ID: References: <20180410195007.GI3094@brightrain.aerifal.cx> <20180410203206.GJ3094@brightrain.aerifal.cx> <20180410205032.GL3094@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c122ab042456a05698530fd" X-Trace: blaine.gmane.org 1523395534 27846 195.159.176.226 (10 Apr 2018 21:25:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Apr 2018 21:25:34 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12715-gllmg-musl=m.gmane.org@lists.openwall.com Tue Apr 10 23:25:30 2018 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.84_2) (envelope-from ) id 1f60le-00078f-1y for gllmg-musl@m.gmane.org; Tue, 10 Apr 2018 23:25:30 +0200 Original-Received: (qmail 17772 invoked by uid 550); 10 Apr 2018 21:27:37 -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 17754 invoked from network); 10 Apr 2018 21:27:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=ghhF8DKkzgAesdpmRjQ8tQGngfcuuZhvo0EmzTrEUTI=; b=hoSBBLlG2MQHXHvd28R6dehEHAxZHu4b/4m+fIJId95yH/2uRZNdm8K3jhvczLPXUu OvKNQORl5iB+XRplb1UNO05aQe3I8QD055qajwPNNfKlFdevOcwN4/TqL52CuQsbu3ns vcxfuNauedWMrUhKM7OZlvW6fgcY/i1xPxEn1fh44IOWOhbuEvBGn7Q+pNSN48Mky3O+ xjK93kHTmPs5YcOvRHk+l+VMvgQC/REb6Nx4EdaO6Gxo5IGTxXZQ1VwmZLaoowKsMdYk +vwEEKdWlxclFKM/KPw9eO4Md2izWfZH8VI7KBVRqnJZ9xzxgLnB0YxAsoPHNc8eMzQk Oq3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ghhF8DKkzgAesdpmRjQ8tQGngfcuuZhvo0EmzTrEUTI=; b=A6iC0irQH/oLoD5GwfVYmhqybYzdpd/bCxt6nRLQRvlrt39WMfDxaZkUcUY6qItD8v xi5yd6/rzhg9XlrysALWdFqqCdQwue6O6pIrwC+2JcteiFY/OFQEjRZiGNxCY0YQ43Eu rFBy0rXy5QnoBczsI/mKEM0clwHJTjCgaj1c8A8tdlobYPZY37nOJLaAjCy7QxOjU5Jm r08GS2lW/h6dFS5DJiL3VDMuF6odFGvNS7XvMIvHFEwguWG8C6ZuMhwT0cvo6vzXxQY/ yJXOK5+Q/CNP1LhlujhFiY7KKDXWltz4DUeA2W/HI6te4P2PkvqQvF1G88Wmhj8/ZcZl PZgg== X-Gm-Message-State: ALQs6tApNpnf0hIzkkdO0auLR+tLrXO1D7rOc8FOvhrMr6FzlZ3rFZ5O Jlq7Az9898CCIioZZOp3sRTZS9kuYEQnbvDNLh8D9w== X-Google-Smtp-Source: AIpwx49nj+2ALBBszm9uua94kYWpQLUCKSlFTmYt5e/mFsLFVgyay8BG1IV1JA3jFJmDR4240/x/MJ8hAGlXQ3658nw= X-Received: by 10.237.46.196 with SMTP id k62mr3318313qtd.207.1523395644764; Tue, 10 Apr 2018 14:27:24 -0700 (PDT) In-Reply-To: <20180410205032.GL3094@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12699 Archived-At: --94eb2c122ab042456a05698530fd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 10, 2018 at 5:50 PM, Rich Felker wrote: > On Tue, Apr 10, 2018 at 05:41:46PM -0300, dgutson . wrote: > > On Tue, Apr 10, 2018 at 5:32 PM, Rich Felker wrote: > > > > > On Tue, Apr 10, 2018 at 05:23:12PM -0300, dgutson . wrote: > > > > On Tue, Apr 10, 2018 at 4:50 PM, Rich Felker > wrote: > > > > > > > > > The OpenBSD catan implementation we're using has a number of > > > > > nonsensical "overflow" (goto ovrf) conditions that aren't errors, > > > > > reported by mepholic on irc. I think the attached patch fixes the= m > > > > > without introducing new problems, but I'm not sure if any other > > > > > problems remain. > > > > > > > > > > Note that, of the three cases removed: > > > > > > > > > > 1. Is not an exceptional case at all, and made no sense to begin > with.. > > > > > > > > > > 2. Is only exceptional if x and a are both zero; atan(2x,0) is > > > > > perfectly well-defined. > > > > > > > > > > 3. Is only possible if y=3D=3D1.0 and x=3D=3D0.0, which is the on= ly real > > > > > exceptional case for atan: z=3D=3DI. > > > > > > > > > > > > > > > > > Besides the trigonometric case, are you considering de-normalized > > > numbers, > > > > such as 4.94066e-324 as divisor? > > > > For example: > > > > double x =3D 1.0; > > > > double y =3D 5E-324; > > > > x / y is inf, and y !=3D 0.0. > > > > Shouldn't 'a' be checked against that number or its absolute value = >=3D > > > > minimum? > > > > > > Can you clarify where you think something goes wrong? > > > > > > > - if (a =3D=3D 0.0) > > - goto ovrf; > > > > t =3D y + 1.0; > > a =3D (x2 + t * t)/a; > > > > > > The check you removed does not look correct for me because what I > mentioned.. > > However, shouldn't you check, before the division, that a is not the > > nearest to zero (+ or -) denormalized representable double, > > in order to avoid ending in inf? > > Here a=3Dx=C2=B2+(y-1)=C2=B2, so unless both x=3D=3D0 and y=3D=3D1, the s= mallest a can be > I was worried by the case when x is 0 and y is the next (or previous) representable value nearest to 1.0; the y =3D=3D 1.0 check will fail, but t= he division may get big; so I did a small program and verified that the result of the division is about 3.24519e+32 when going towards negative and 8.11296e+31 when going towards positive, so everything is OK (I didn't dig in the atan2 arguments though). > is DBL_EPSILON=C2=B2. When a is small, the numerator in the last line is > also small (x=C2=B2+(1+y)=C2=B2 < 2) so dividing by a does not overflow. > > Rich > --=20 Who=E2=80=99s got the sweetest disposition? One guess, that=E2=80=99s who? Who=E2=80=99d never, ever start an argument? Who never shows a bit of temperament? Who's never wrong but always right? Who'd never dream of starting a fight? Who get stuck with all the bad luck? --94eb2c122ab042456a05698530fd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Apr 10, 2018 at 5:50 PM, Rich Felker <dalias@libc.org> wrote:
On Tue, Apr 10, 2018 at 05:41:46PM -0300, dgutson . wrote:
> On Tue, Apr 10, 2018 at 5:32 PM, Rich Felker <dalias@libc.org> wrote:
>
> > On Tue, Apr 10, 2018 at 05:23:12PM -0300, dgutson . wrote:
> > > On Tue, Apr 10, 2018 at 4:50 PM, Rich Felker <dalias@libc.org> wrote:
> > >
> > > > The OpenBSD catan implementation we're using has a = number of
> > > > nonsensical "overflow" (goto ovrf) conditions= that aren't errors,
> > > > reported by mepholic on irc. I think the attached patch= fixes them
> > > > without introducing new problems, but I'm not sure = if any other
> > > > problems remain.
> > > >
> > > > Note that, of the three cases removed:
> > > >
> > > > 1. Is not an exceptional case at all, and made n= o sense to begin with..
> > > >
> > > > 2. Is only exceptional if x and a are both zero; atan(2= x,0) is
> > > >=C2=A0 =C2=A0 perfectly well-defined.
> > > >
> > > > 3. Is only possible if y=3D=3D1.0 and x=3D=3D0.0, which= is the only real
> > > >=C2=A0 =C2=A0 exceptional case for atan: z=3D=3DI.
> > > >
> > >
> > >
> > > Besides the trigonometric case, are you considering de-norma= lized
> > numbers,
> > > such as 4.94066e-324 as divisor?
> > > For example:
> > >=C2=A0 =C2=A0 =C2=A0double x =3D 1.0;
> > >=C2=A0 =C2=A0 =C2=A0double y =3D 5E-324;
> > > x / y is inf, and y !=3D 0.0.
> > > Shouldn't 'a' be checked against that number or = its absolute value >=3D
> > > minimum?
> >
> > Can you clarify where you think something goes wrong?
> >
>
> -=C2=A0 =C2=A0 =C2=A0if (a =3D=3D 0.0)
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto ovrf;
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0t =3D y + 1.0;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0a =3D (x2 + t * t)/a;
>
>
> The check you removed does not look correct for me because what= I mentioned..
> However, shouldn't you check, before the di= vision, that a is not the
> nearest to zero (+ or -) denormalized representable double,
> in order to avoid ending in inf?

Here a=3Dx=C2=B2+(y-1)=C2=B2, so unless both x=3D=3D0 and y=3D=3D1, = the smallest a can be

I was worried by = the case when x is 0 and y is the next (or previous) representable value ne= arest to 1.0; the y =3D=3D 1.0 check will fail, but the division may get bi= g; so I did a small program and verified that the result of the division is= about=C2=A03.24519e+32 when going towards negative and 8.11296e+31 when go= ing towards positive, so everything is OK (I didn't dig in the atan2 ar= guments though).
=C2=A0
is DBL_EPSILON=C2=B2. When a is small, the numerator in the last line is also small (x=C2=B2+(1+y)=C2=B2 < 2) so dividing by a does not overflow.=

Rich



--
Who=E2=80=99s got the sweetest disposition= ?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an a= rgument?
Who never shows a bit of temperament?
Who's never wrong = but always right?
Who'd never dream of starting a fight?
Who get = stuck with all the bad luck?
--94eb2c122ab042456a05698530fd--