| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:date:from:to:subject:message-id:reply-to | |
| :references:mime-version:content-type:in-reply-to; q=dns; s= | |
| default; b=xTzUnyh+LBAQG4lfK0DRjlZ5JnyEnRqBpL/vItjdDahEqW02CZhrk | |
| R1cq5hAgCcgbml8oPlEWCC4mImPzF0MjIq/9OrSD5s/+FQwgWPCQr4yXTFhuvGHW | |
| iMFWkKDPBIgjxMi0sUPGBUDhtqe5+kSUxHdVDA2e/EC8us7hhY6e38= | |
| DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:date:from:to:subject:message-id:reply-to | |
| :references:mime-version:content-type:in-reply-to; s=default; | |
| bh=dYfapzmbrfBzDap3wmGUZdkSD1Q=; b=Ue3bHSpkfaDH67LN7aKCyyJKos/d | |
| Qv7mk3sCf8G0zG+WzObj/tszC/BquZnU+d2KSegnwT2IHYWUQ3R6VrnEN+YzLzrL | |
| kFSGuR9A8YOn8A6JhLW/HeJ2wiIUsEcjqP3d05HDJlLwrvCRWV5T/752vp2Z8MAU | |
| RRM1aFtkRsfz+Qk= | |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Authentication-Results: | sourceware.org; auth=none |
| X-Spam-SWARE-Status: | No, score=-101.3 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= |
| X-HELO: | mout.kundenserver.de |
| Date: | Mon, 9 Jul 2018 21:07:29 +0200 |
| From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: FPE in localtime.cc |
| Message-ID: | <20180709190729.GF27673@calimero.vinschen.de> |
| Reply-To: | cygwin AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <CY4PR09MB1302CB30716988BB7BB61EF3A5440 AT CY4PR09MB1302 DOT namprd09 DOT prod DOT outlook DOT com> <20180709164947 DOT GE27673 AT calimero DOT vinschen DOT de> <cf7088aa-9cb5-bc43-1bf2-6acc0603b57b AT SystematicSw DOT ab DOT ca> |
| MIME-Version: | 1.0 |
| In-Reply-To: | <cf7088aa-9cb5-bc43-1bf2-6acc0603b57b@SystematicSw.ab.ca> |
| User-Agent: | Mutt/1.9.2 (2017-12-15) |
--RYJh/3oyKhIjGcML
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Jul 9 11:16, Brian Inglis wrote:
> On 2018-07-09 10:49, Corinna Vinschen wrote:
> > On Jul 9 15:47, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:
> >> Hello,
> >>
> >> the following sample coredumps with FPE at localhost.cc:1962 with the =
latest snapshot (6/29/2018):
> ...
> > You can simplify your testcase by not calling any time functions:
> >=20
> > #define _GNU_SOURCE
> > #include <fenv.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> >=20
> > #define SECSPERDAY 86400
> >=20
> > int main(int argc, char **argv)
> > {
> > feenableexcept(FE_ALL_EXCEPT);
> > long tdays =3D argc > 1 ? strtol (argv[1], NULL, 10) : 189;
> > long seconds =3D tdays * SECSPERDAY + 0.5;
> > printf ("%ld\n", seconds);
> > }
> >=20
> > This generates a SIGFPE on Linux as well.
> >=20
> > The line computing seconds is the same line as used by the localtime
> > function. Cygwin shares the entire localtime code with the various
> > BSDs, so I guess they would have the same problem.
> What is that line meant to do? Am I missing something?
> It should be the equivalent of (tdays*SECSPERDAY*2 + 1)/2!
> It converts an integer value to double, adds 1/2, and throws it away on
> conversion back, unless the intermediate has insufficient mantissa bits, =
in
> which case, it loses the low bits?
You may want to ask the original author why he used FP arithmetic in
this place. Maybe it's a way to avoid integer overflow. I'm reluctant
to change this given that this code is still used in BSD as well.
> > Bottom line is, don't bulk enable FP exceptions, but only if you really
> > need it for certain parts of your code. Don't expect library functions
> > to be SIGFPE clean under all circumstances.
>=20
> Maybe selectively enable specific FPEs to check for where needed.
> Or be careful what you wish for, as you just might get a lot more than you
> bargained for ;^>
That's what I meant.
Corinna
--=20
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--RYJh/3oyKhIjGcML
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAltDsnEACgkQ9TYGna5E
T6Dazg//R9tlHG5qVRKSI8jtW7bnzvjPExX164/Xkht4GdJF4CUeGEk3QNwyEEKc
bo4V02W3u5TzlJZVae65tmDZ0DTkhHoF+bxWnD6VcjCCZn2Ezd+oW2+gk8SYSZyy
lKKKJSW2Kyyg+qW3wlAviP6UBXbZ0M25BUhI6qzCVW4/9NxEZxPkvkJZHyMS/AID
NqtAV6LfUyCb0oeyMacKAngVVj943bVeZMttVldiILlaiHIE9vtS8EqflfxJUwTb
R1UG0SJyueK0gzg8XcIa/kOKn6mArjA2RamzK9F+TlK4yQI9KD1s6QEJCCMAxSt7
0Qdu0R6Ji42Yy9NuEF4Db2q58RE0OMgfwwJXojtfJHBkSRDDb6ZyIDsrDLsnb6aO
HZkTWfBVs+F61QETw/moDw1WfB7fhlG7dAHC5EkSpiSsc1wi+9tUtVAwCmgk6ShK
3UmXDrW1IPBWuaCgcHdBvWixqV2M6Ns9ddM/z1PMu45JNf3QQn6yrAFuGBFNbt48
JudTd5SA7jC7hu+FKpppkHRPBG7fWxmnVREq+qNwlO+yxhBQ7+TTvKpb079jmcI/
/85xfTiDV9YP5BjAD1cGeZxQmS5ducnl/WwFdmYVS+iOBYcHdtDaxsgyOdyd0qh7
+8Cr54Hqkb0pvc51KHe2B5ALUGnxycuF0hsWNOE2qugOYuuMRwY=
=w5Hc
-----END PGP SIGNATURE-----
--RYJh/3oyKhIjGcML--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |