httptime.c:Ns_ParseHttpTime() uses mt-unsafe call to
timegm() call. This one is not safe on Darwin.
Corrective measure is to undefine HAVE_TIMEGM
for Darwin builds, hence falling back to mktime() call
which is thread-safe. At least, this is what its
manpage says.
Logged In: YES
user_id=21885
Link to Darwin manpage:
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/timegm.3.html
No where in the man page does it say timegm() is unsafe.
However, in the AOLserver chat, you said:
IRC [10:38] <archiware> Dossy, there was a bugreport on
non-mt-safe usage of some time functions
IRC [10:38] <archiware> you remember which bug# was that?
IRC [10:38] <archiware> I think I found another troublesome
instance -> timegm() call in httptime.c
IRC [10:39] <archiware> This cores the server definitely
IRC [10:39] <archiware> I was able to reproduce this in Mac OSX
IRC [10:41] <archiware> I temporarily word-around this by
removing HAVE_TIMEGM from the makefile
IRC [10:41] <archiware> and making: t = mktime(&tm) -
(time_t)timezone;
IRC [10:41] <archiware> This seams to work, but I'm not sure
if this is the right way.
Do you have a reproducible case where the crash can be
demonstrated? What version of OS X? Does it still crash
the latest version of OS X?
Logged In: YES
user_id=95086
As far as I remember, I went to www.opendarwin.org and peeked
into sources after I got my server cored down several times at
various places...
Reproducible case I can't recall of any more. It was not something
you could easily reproduce, as its usually with mt-unsafe issues.
But, go ahead and look into the sources of Darwin and you will see...
Logged In: YES
user_id=332185
Is there any reason we wouldn't want to just always use
mktime() instead?
nsd/httptime.c:
Change:
#ifdef HAVE_TIMEGM
t = timegm(&tm);
#else
t = mktime(&tm) - timezone;
#endif
return t;
To:
t = mktime(&tm) - timezone;
Logged In: YES
user_id=95086
Good question...
I dunno. I've checked timegm on 3 platforms we use AS on:
Linux, Solaris and Mac OSX. All of them have the mktime and
on all of them is mktime thread-safe. Solaris has no timegm,
Mac OSX has thread-unsafe timegm and Linux as well.
Question is: will you always have timezone variable defined?
At the moment I'm solving that part pretty conservatively
like this:
#ifdef HAVE_TIMEGM
static Ns_Mutex lock;
#endif
#ifdef HAVE_TIMEGM
Ns_MutexLock(&lock);
t = timegm(&tm);
Ns_MutexUnlock(&lock);
#else
t = mktime(&tm) - timezone;
#endif
and pay little concurrency/performance for greater flexibility and stability.
Cheers
Zoran