public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr@ncbi.nlm.nih.gov>
To: "'cygwin@cygwin.com'" <cygwin@cygwin.com>
Subject: FPE in localtime.cc
Date: Mon, 09 Jul 2018 15:47:00 -0000	[thread overview]
Message-ID: <CY4PR09MB1302CB30716988BB7BB61EF3A5440@CY4PR09MB1302.namprd09.prod.outlook.com> (raw)

Hello,

the following sample coredumps with FPE at localhost.cc:1962 with the latest snapshot (6/29/2018):

#define _GNU_SOURCE
#include <fenv.h>
#include <time.h>
#include <stdio.h>

static time_t s_Time;

static void fun(void)
{
  char buf[40];
  strftime(buf, sizeof(buf), "%m/%d/%y %H:%M:%S", localtime(&s_Time));
  printf("%s\n", buf);
}

int main()
{
  feenableexcept(FE_ALL_EXCEPT);
  time(&s_Time);
  fun();
}

$ cat a.exe.stackdump
Exception: STATUS_FLOAT_INEXACT_RESULT at rip=001800BBA24
rax=000000000000016D rbx=000000005B43498E rcx=00000000000001EC
rdx=1845C8A0CE512957 rsi=0000000051EB851F rdi=2CC3D8D4A245F203
r8 =0000000000F92B80 r9 =00000000FFFFFFED r10=00000000000007E2
r11=000000000000000C r12=00000000FFFFFFFF r13=0000000080000000
r14=00000000000000BD r15=00000000000007E2
rbp=000000007FFFFFFF rsp=00000000FFFFCA70
program=C:\Cygwin64\...\a.exe, pid 14232, thread main
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B

Removing the first line of the main() function lets the program run successfully.
The same code runs fine unmodified on Linux.

$ gcc -Wall sample.c -lm
$ ./a.out
07/09/18 11:44:26

Any ideas?

Thanks,
Anton Lavrentiev


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

             reply	other threads:[~2018-07-09 15:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 15:47 Lavrentiev, Anton (NIH/NLM/NCBI) [C] [this message]
2018-07-09 16:49 ` Corinna Vinschen
2018-07-09 17:17   ` Brian Inglis
2018-07-09 19:07     ` Corinna Vinschen
2018-07-10 13:35       ` cyg Simple
2018-07-11  1:30         ` Brian Inglis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4PR09MB1302CB30716988BB7BB61EF3A5440@CY4PR09MB1302.namprd09.prod.outlook.com \
    --to=lavr@ncbi.nlm.nih.gov \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).