This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Fix possible infinite loop in hires_ms::timeGetTime_ns()
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Tue, 20 Mar 2012 19:03:09 +0100
- Subject: Re: [PATCH] Fix possible infinite loop in hires_ms::timeGetTime_ns()
- References: <4F68C2DA.8050909@t-online.de>
- Reply-to: cygwin-patches at cygwin dot com
On Mar 20 18:48, Christian Franke wrote:
> 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 (;;)
> ;
> }
Wow, thanks a lot for figuring this out and the patch. This could
explain some spurious hangs. Patch applied.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat