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

[PATCH] win32_async_check() can still loop indefinitely

Thread Next
From:
Robert May
Date:
January 12, 2007 17:47
Subject:
[PATCH] win32_async_check() can still loop indefinitely
Message ID:
45A82EF8.60501@popeslane.clara.co.uk
Previous patch on this subject:
http://www.xray.mpe.mpg.de/cgi-bin/w3glimpse2html/perl5-porters/2006-03/msg00551.html

I have been investigating a reported bug with Win32::GUI relating to 
fork and sleep hanging.  Bug report and follow-up information at:
https://sourceforge.net/tracker/index.php?func=detail&aid=1631028&group_id=16572&atid=116572

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 
happening.

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,
Rob.





Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About