From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63013 invoked by alias); 9 Jul 2018 16:49:53 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 63004 invoked by uid 89); 9 Jul 2018 16:49:52 -0000 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=nih, NLM, NIH, nlm X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (217.72.192.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jul 2018 16:49:50 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.183]) with ESMTPSA (Nemesis) id 0Lzai2-1g6lSA2ASI-014o6Y for ; Mon, 09 Jul 2018 18:49:48 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 31A97A8061D; Mon, 9 Jul 2018 18:49:47 +0200 (CEST) Date: Mon, 09 Jul 2018 16:49:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: FPE in localtime.cc Message-ID: <20180709164947.GE27673@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="S1BNGpv0yoYahz37" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-07/txt/msg00082.txt.bz2 --S1BNGpv0yoYahz37 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2329 On Jul 9 15:47, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote: > Hello, >=20 > the following sample coredumps with FPE at localhost.cc:1962 with the lat= est snapshot (6/29/2018): >=20 > #define _GNU_SOURCE > #include > #include > #include >=20 > static time_t s_Time; >=20 > static void fun(void) > { > char buf[40]; > strftime(buf, sizeof(buf), "%m/%d/%y %H:%M:%S", localtime(&s_Time)); > printf("%s\n", buf); > } >=20 > int main() > { > feenableexcept(FE_ALL_EXCEPT); > time(&s_Time); > fun(); > } >=20 > $ cat a.exe.stackdump > Exception: STATUS_FLOAT_INEXACT_RESULT at rip=3D001800BBA24 > rax=3D000000000000016D rbx=3D000000005B43498E rcx=3D00000000000001EC > rdx=3D1845C8A0CE512957 rsi=3D0000000051EB851F rdi=3D2CC3D8D4A245F203 > r8 =3D0000000000F92B80 r9 =3D00000000FFFFFFED r10=3D00000000000007E2 > r11=3D000000000000000C r12=3D00000000FFFFFFFF r13=3D0000000080000000 > r14=3D00000000000000BD r15=3D00000000000007E2 > rbp=3D000000007FFFFFFF rsp=3D00000000FFFFCA70 > program=3DC:\Cygwin64\...\a.exe, pid 14232, thread main > cs=3D0033 ds=3D002B es=3D002B fs=3D0053 gs=3D002B ss=3D002B >=20 > Removing the first line of the main() function lets the program run succe= ssfully. > The same code runs fine unmodified on Linux. >=20 > $ gcc -Wall sample.c -lm > $ ./a.out > 07/09/18 11:44:26 >=20 > Any ideas? You can simplify your testcase by not calling any time functions: #define _GNU_SOURCE #include #include #include #define SECSPERDAY 86400 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); } This generates a SIGFPE on Linux as well. 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. 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. Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --S1BNGpv0yoYahz37 Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAltDkisACgkQ9TYGna5E T6Dk+w/7B1XN2z/4VeH+HRe1IkLqjq3qeAqffqaUZO+PC9K/i+w/7DLYEx7su7Og UCEuclg1fLHeClrkdvNMbYSfYVA93ZgNo4GCQ9VgmYmVeBWJhAlh+GUOI5pHtali 2kelu/s+yvoFkjnfe7/G7JJT8FaLwx8B1KkRA/j5tJ8fiVqFff1oGffAZ3MBq9L7 7JA8bHt1tBXrihVNC6/ra/rOFtFRXn3PZWB1MdgewkWqwAfmC/mTofDl4Rs+9Rit NbDoHkM9edqulz8EJVub181AmNAPzg56hOQ1czVP7IUpa4wpi7rIkOpTL6K0S2i7 uSbBb1Ide1JkUBk9/ivjgJoNcMSH4A/UExQv15MaGIIhWRr0RmKfFQmPyJkNJT71 iMhjl0Rso/irFti2a9nKY0t0/URED1v7dU+oFisageNOOVCmdhvuh45dA02aHrtK 1/J6v4vlX8w7QoiUdrtKcqQ4OohfssN2cYct5JrbsEnjVRdZ6HTC8/BrL4n9M/ay IZhktrgkW2xmTxw6AEzoR+Txfsc2rtNbYaEcP/Fx81ci7DlFCR7g1i/mJb3R73WI frqp9n58W1T5TBwFwoNBu+yyiIkf7pyy/Ry73OLgvz0EmI3fwXghtb3jzbx/jXPZ U1FkXO5XpQUaQ7ByO07qWTwAZcPLcG54NSzrTjnPj4j70+Fz6eI= =qUir -----END PGP SIGNATURE----- --S1BNGpv0yoYahz37--