SIGSEGV in localtime()?

Igor Pechtchanski pechtcha@cs.nyu.edu
Mon Feb 24 04:19:00 GMT 2003


On Sun, 23 Feb 2003, Marco Giovannini wrote:

> I've got this simple piece of code:
>
> time_t current_time;
> struct tm *boot_time;
> current_time = time(NULL);
> boot_time = localtime(&current_time);
>
> that is very stupid and *should* run on every posix machine, but..
> with the latest cygwin dll release (1.3.20) I receive this error:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x6100d074 in cygwin_attach_handle_to_fd () from /usr/bin/cygwin1.dll
>
> Two more notes:
>   - In the cygwin dll release I had before updating the last week (I cannot
> remember which one was, but I know it was two-three months old or so),
> localtime() worked without trobles.
>   - It seems that I receive the same error also with gmtime and mktime.
>
> I cannot believe that this is an error of my stupid program...
> Does anybody have the same problem?
>
> Thank you all for your help,
> Marco Giovannini

Marco,

I was unable to reproduce your problem on Win2k SP2 (cygwin-1.3.20-1).  I
used the attached program.  It compiled fine (with "gcc -Wall") and ran
correctly, with the following output:

$ date && ./lt
Sun Feb 23 20:41:44 EST 2003
44:41:20 23/1/103 (0) [53] 0
$

The information you've provided is really not enough to even venture a
guess as to what went wrong.  Please provide at least the following:

- The output of "cygcheck -svr", as an uncompressed text attachment, as
  per <http://cygwin.com/bugs.html>
- The exact compilation command line
- The backtrace of the failed program (either from gdb, or from addr2line)
- The output of "strace yourprog" (probably compressed, it might be large)

Feel free to look over the last two for clues before sending them to the
list.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
  -- /usr/games/fortune
-------------- next part --------------
#include <time.h>
#include <stdio.h>

int main(int ac, char **av) {
  time_t current_time;
  struct tm *boot_time;
  current_time = time(NULL);
  boot_time = localtime(&current_time);

  fprintf(stderr, "%d:%d:%d %d/%d/%d (%d) [%d] %d\n", boot_time->tm_sec,
      boot_time->tm_min, boot_time->tm_hour, boot_time->tm_mday,
      boot_time->tm_mon, boot_time->tm_year, boot_time->tm_wday,
      boot_time->tm_yday, boot_time->tm_isdst);

  return 0;
}
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list