From: "Brozinski, Stefan" <stefan.brozinski@materna.de>
To: "'pthreads-win32@sources.redhat.com'"
<pthreads-win32@sources.redhat.com>
Subject: Dangerous: localtime_r, gmtime_r
Date: Tue, 23 Sep 2003 12:06:00 -0000 [thread overview]
Message-ID: <5BD61062E524E244ADD87F7988480EC3C82369@hb-castor.hb.buc.materna.com> (raw)
Hi all,
there is a problem with the current implementation of the thread safe
version of "localtime" and "gmtime" currently implemented as a macro in
<pthread.h>.
The current definition for localtime_r is:
#define localtime_r( _clock, _result ) \
( *(_result) = *localtime( (_clock) ), \
(_result) )
The problem is that localtime() may return NULL. At least Microsoft's
implementation in MSVCRT[D].DLL does in fact return NULL if certain
conditions are met. Thus, a page fault may occur when using this
implementation.
I suggest to change the implementation from the current #define to a 'real'
function like:
struct tm *localtime_r(time_t *_clock, struct tm *_result)
{
struct tm *p = localtime(_clock);
if (p)
*(_result) = *p;
return p;
}
Regards
Stefan
reply other threads:[~2003-09-23 12:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5BD61062E524E244ADD87F7988480EC3C82369@hb-castor.hb.buc.materna.com \
--to=stefan.brozinski@materna.de \
--cc=pthreads-win32@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).