svn commit: r248672 - head/lib/libc/stdtime

Dimitry Andric dim at FreeBSD.org
Sun Mar 24 02:40:50 UTC 2013


On Mar 24, 2013, at 02:35, Dimitry Andric <dim at FreeBSD.org> wrote:
> Author: dim
> Date: Sun Mar 24 01:35:37 2013
> New Revision: 248672
> URL: http://svnweb.freebsd.org/changeset/base/248672
> 
> Log:
>  Compile contrib/tzcode/stdtime/localtime.c with -fwrapv, since it relies
>  on signed integer overflow wrapping.  Otherwise mktime(3) and timegm(3)
>  can hang, in case the timestamp passed in struct tm is not representable
>  in a time_t.  Specifically, any timestamp after 2038-01-19 03:14:07, in
>  combination with a 32-bit time_t.

I first noticed this when Squid on a i386 machine started to hang every
now and then, and started consuming 100% CPU in such cases.  After
rebuilding Squid with debug info, I found it hung in timegm(3), because
some web servers apparently like to pass Last-Modified dates of "Fri, 31
Dec 9999 23:59:59 GMT", most likely to prevent caching.

Note this is not an issue on amd64, since time_t is 64-bit there, so
even a struct tm with tm_year=INT_MAX would work with mktime(3) and
timegm().



More information about the svn-src-all mailing list