develooper Front page | perl.perl5.porters | Postings from January 2007

[PATCH] win32_async_check() can still loop indefinitely

Thread Next
Robert May
January 12, 2007 17:47
[PATCH] win32_async_check() can still loop indefinitely
Message ID:
Previous patch on this subject:

I have been investigating a reported bug with Win32::GUI relating to 
fork and sleep hanging.  Bug report and follow-up information at:

The bug report is on WinXP(SP2) and I can reproduce the problem on 
Win98, but not on Win2K - in all cases with AS Perl 5.8.8 builds 817 and 
  819, which both include changes 26379 and 27527 from blead.

The simplest example I can come up with is:

perl -MWin32::GUI -e "Win32::GUI::GetOpenFileName(); alarm(0); sleep(1)"

which hangs in the sleep(), at 100% CPU usage.

Debugging shows that MsgWaitForMultipleObjects() in win32_msgwait() is 
always returning (WAIT_OBJECT_0 + 0) indicating that one or more 
messages are pending, and the timeout never happens.  A PeekMessage() 
does not indicate any messages in the queue (it returns 0), but does 
stop the loop spinning.

The documentation for MsgWaitForMultipleObjects suggests that the 
filtered PeekMessage() calls in win32_async_check() should be enough to 
mark any outstanding messages as old, but this does not appear to be 

The attached patch below resolves this issues, by always calling 
PeekMessage() to mark messages as old, and I don't think it will have 
any other side effects.  However, I won't pretend that I've really got 
to the bottom of what's going on here.

Is this patch acceptable, or should I raise a bug report so that someone 
else with a better understanding than can look further into the issue?

Patch is against latest blead win32/win32.c

Thanks for any assistance,

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About