<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7601.17998"></HEAD>
<BODY>
<DIV><FONT size=2 face=Arial><SPAN class=665455113-17122012>Hello
everybody,</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=665455113-17122012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=665455113-17122012>There is a
potential bug (division by zero) in the gettimeofday() function which should be
fixed with suggested patch below.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN class=665455113-17122012>The point is to move
the 'QueryCounter = 1' behind calling
QueryPerformanceFrequency().</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN class=665455113-17122012>Otherwise another
thread (within current process) could pre-empt the current one right after
'QueryCounter = 1',</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN class=665455113-17122012>and thus would
work with an uninitialized (i.e. zero) Frequency variable.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=665455113-17122012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=665455113-17122012>Thanks,</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=665455113-17122012>Hubert.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=665455113-17122012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=665455113-17122012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Index:
gtod.c<BR>===================================================================<BR>---
gtod.c (revision 3414)<BR>+++ gtod.c (working copy)<BR>@@ -62,6 +62,9
@@<BR> int gettimeofday(struct timeval *ptv, void
*ignored)<BR> {<BR> static int QueryCounter =
2;<BR>+ static LARGE_INTEGER Frequency = {10000000,0}; /* prevent division
by 0 */<BR>+ static LARGE_INTEGER Offset; /* counter offset for right
time*/<BR>+ static LARGE_INTEGER LastCounter;<BR> FILETIME
CurrentTime;<BR> UNREFERENCED_PARAMETER(ignored);
<BR> <BR>@@ -69,9 +72,6
@@<BR> <BR> if(QueryCounter)<BR> {<BR>- static
LARGE_INTEGER Frequency;<BR>- static LARGE_INTEGER Offset; /* counter
offset for right time*/<BR>- static LARGE_INTEGER
LastCounter;<BR> LARGE_INTEGER
Time;<BR> LARGE_INTEGER Counter;<BR> <BR>@@ -80,13
+80,15 @@<BR> <BR> if(QueryCounter ==
2)<BR> {<BR>- QueryCounter =
1;<BR>- if(!QueryPerformanceFrequency(&Frequency))<BR>+ if(QueryPerformanceFrequency(&Frequency))<BR> {<BR>+ QueryCounter
= 1; // But now the Frequency is
valid!<BR>+ }<BR>+ else<BR>+ {<BR> QueryCounter
= 0;<BR> Frequency.QuadPart = 10000000; /* prevent
division by 0
*/<BR> }<BR>- <BR> /* get
time as a large integer */<BR> Counter.HighPart &=
0x7FL; /* Clear high bits to prevent overflow
*/<BR> Offset.LowPart =
CurrentTime.dwLowDateTime;<BR></DIV></FONT><br clear=all> This message and attachment(s) are intended solely for use by the addressee and may contain information that is privileged, confidential or otherwise exempt from disclosure under applicable law.
If you are not the intended recipient or agent thereof responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify the sender immediately by telephone and with a 'reply' message.
Thank you for your co-operation.
</BODY></HTML>