[PATCH] Fix possible infinite loop in hires_ms::timeGetTime_ns()

Christian Franke Christian.Franke@t-online.de
Tue Mar 20 17:48:00 GMT 2012


ntdll.h:SharedUserData misses a volatile qualifier. This (at least) may 
result in an infinite loop in hires_ms::timeGetTime_ns(). Fortunately 
this could only happen if LowPart wraps around during the function call.

Generated code:

$ objdump -d -C times.o
...
1160 <hires_ms::timeGetTime_ns()>:
1160: 55                 push   %ebp
1161: 8b 15 0c 00 fe 7f  mov    0x7ffe000c,%edx
1167: 3b 15 10 00 fe 7f  cmp    0x7ffe0010,%edx
116d: 89 e5              mov    %esp,%ebp
116f: a1 08 00 fe 7f     mov    0x7ffe0008,%eax
1174: 75 02              jne    1178 <hires_ms::timeGetTime_ns()+0x18>
1176: 5d                 pop    %ebp
1177: c3                 ret
1178: eb fe              jmp    1178 <hires_ms::timeGetTime_ns()+0x18>
...


This function results in the same code:

LONGLONG hires_ms::timeGetTime_ns ()
{
   LARGE_INTEGER t;
   t.HighPart = SharedUserData.InterruptTime.High1Time;
   t.LowPart = SharedUserData.InterruptTime.LowPart;
   if (t.HighPart == SharedUserData.InterruptTime.High2Time)
     return t.QuadPart;

   for (;;)
     ;
}


Christian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: volatile-userdata.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20120320/b21b267e/attachment.bin>


More information about the Cygwin-patches mailing list