[erlang-bugs] Bug: local_to_univ does not handle -1 result from mktime (with patch)

Kenji Rikitake kenji.rikitake@REDACTED
Sat Nov 1 13:56:14 CET 2008


Confirmed the following bug behavior on FreeBSD 6.3-RELEASE too.
See FreeBSD /usr/src/lib/libc/stdtime/localtime.c for the details.
(mktime() and time1())

FYI
Kenji Rikitake

In the message <23B2C08A-4A52-482E-96D1-27189F0A8C19@REDACTED>
dated Sat, Nov 01, 2008 at 07:49:59AM +0100,
Paul Guyot <pguyot@REDACTED> writes:
> Hello,
> 
> I found a bug in Erlang/OTP R12B-4 that occurs on FreeBSD 7.0 with TZ  
> set to UTC. On such systems, mktime(3) returns -1 when is_dst is set  
> to true. According to SUSv3, the OS can return -1 when the time since  
> Epoch cannot be represented, and therefore FreeBSD is perfectly  
> allowed to do so.
> 
> http://www.opengroup.org/onlinepubs/009695399/functions/mktime.html
> 
> In other words, erlang:localtime_to_universaltime/2 may return {{1969,  
> 12, 31}, {23, 59, 59}} (-1) whenever the (DateTime, IsDST) combination  
> is invalid (DateTime is invalid or IsDST is true and there is no valid  
> DST representation for the given DateTime). This function is called by  
> calendar:local_time_to_universal_time_dst/1 which unexpectedly fails.
> 
> FreeBSD 7.0 with TZ set to UTC:
> 1> calendar:local_time_to_universal_time_dst({{2008, 8, 1}, {0, 0, 0}}).
> ** exception error: bad argument
>      in function  erlang:universaltime_to_localtime/1
>         called as erlang:universaltime_to_localtime({{1969,12,31}, 
> {23,59,59}})
>      in call from calendar:local_time_to_universal_time_dst/1

[rest deleted]



More information about the erlang-bugs mailing list