public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/17646] New: mktime: unpredictable return value for ambiguous time, depends on previous mktime call
@ 2014-11-25 13:38 michael.haubenwallner@ssi-schaefer.com
  2015-08-27 22:24 ` [Bug time/17646] " jsm28 at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: michael.haubenwallner@ssi-schaefer.com @ 2014-11-25 13:38 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17646

            Bug ID: 17646
           Summary: mktime: unpredictable return value for ambiguous time,
                    depends on previous mktime call
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: michael.haubenwallner@ssi-schaefer.com
                CC: drepper.fsp at gmail dot com

Created attachment 7971
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7971&action=edit
ambiguous-mktime.c

Passing struct tm values with tm_isdst=-1 to mktime() from within the
"ambiguous" time range (during the DST backwards-transition), the resulting
time_t value depends on the result of the previous call to mktime().

While the behavior is undefined, it still should be predictable/consistent in
that it either does:
* detect the ambiguous timestamp's DST value to be the same as the current
  timestamp's dst value (seen on AIX), or
* detect the ambiguous timestamp's DST value to always be non-DST
  (seen on HP-UX, Solaris, Windows), or
* detect the ambiguous timestamp's DST value to always be DST
  (not seen anywhere yet).

Compile and run attached test program:
  $ gcc ambiguous-test.c -o ambiguous-test
  $ TZ=Europe/Vienna ./ambiguous-test
2014-10-26 00:37:00 = 1414276620 (1, 7200, CEST)
2014-10-26 01:37:00 = 1414280220 (1, 7200, CEST)
2014-10-26 02:37:00 = 1414283820 (1, 7200, CEST) # first
2014-10-26 03:37:00 = 1414291020 (0, 3600, CET )
2014-10-26 04:37:00 = 1414294620 (0, 3600, CET )
2014-10-26 03:37:00 = 1414291020 (0, 3600, CET )
2014-10-26 02:37:00 = 1414287420 (0, 3600, CET ) # inconsistent with first
2014-10-26 01:37:00 = 1414280220 (1, 7200, CEST)
2014-10-26 00:37:00 = 1414276620 (1, 7200, CEST)
FAILED (inconsistent)

Application developers don't have control over previous mktime() calls, but the
current one only.

However, I'm wondering how this could have gone unnoticed for almost 20 years,
as this IMHO was introduced in 1995 with 'static time_t localtime_offset' in
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=80fd73873bd51e58039983a9416ef3bb97bdac57

Thanks!
/haubi/

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug time/17646] mktime: unpredictable return value for ambiguous time, depends on previous mktime call
  2014-11-25 13:38 [Bug libc/17646] New: mktime: unpredictable return value for ambiguous time, depends on previous mktime call michael.haubenwallner@ssi-schaefer.com
@ 2015-08-27 22:24 ` jsm28 at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-08-27 22:24 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17646

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libc                        |time

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-27 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25 13:38 [Bug libc/17646] New: mktime: unpredictable return value for ambiguous time, depends on previous mktime call michael.haubenwallner@ssi-schaefer.com
2015-08-27 22:24 ` [Bug time/17646] " jsm28 at gcc dot gnu.org

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).