WaitForMultipleObjects loops forever if passed an array of size zero

Troy Rollo wine at troy.rollo.name
Thu Jun 26 00:59:42 CDT 2003


On Thu, 26 Jun 2003 10:16, Alexandre Julliard wrote:
> Troy Rollo <wine at troy.rollo.name> writes:
> > @@ -412,7 +412,7 @@
> >  {
> >      int ret, cookie;
> >
> > -    if (count > MAXIMUM_WAIT_OBJECTS) return STATUS_INVALID_PARAMETER_1;
> > +    if (count > MAXIMUM_WAIT_OBJECTS || count <= 0) return
> > STATUS_INVALID_PARAMETER_1;
>
> This is wrong, 0 is a valid count, and shouldn't cause an infinite
> loop. You'll need to debug this some more.

I see - you're using it for Sleep. It would appear then that the solution is 
to change the condition to (count > MAXIMUM_WAIT_OBJECTS || (count <= 0 && 
!timeout)).

The problem manifests in the Borland Library function "wait()". If you call 
this library function under real Windows when there are no outstanding child 
windows, it returns with an error. Under Wine, it gets stuck in 
WaitForMultipleObjectsEx, although it appears it's waiting for some input 
from wineserver that never comes rather than looping.

I've just tested Win2K under bochs, and WaitForMultipleObjectsEx is returning 
an error of 0x00000057 (ERROR_INVALID_PARAMETER) for wait() without any 
children, and for WaitForMultipleObjectsEx(0, 0, INFINITE, QS_ALLEVENTS, 0);

With the condition as (count > MAXIMUM_WAIT_OBJECTS || (count <= 0 && 
!timeout)), wine's behaviour mirrors that of Win2k, at least for the 
WaitForMultipleObjectsEx(0, 0, INFINITE, QS_ALLEVENTS, 0) case.




More information about the wine-devel mailing list