#67 hang w/ fork + sleep + Win32::GUI->GetOpenFileName

closed-fixed
Robert May
None
5
2007-01-17
2007-01-09
Brad Bowman
No

The "warn 1" never happens:

C:\>perl -MWin32::GUI -e "Win32::GUI->GetOpenFileName(); fork ? sleep(1) && warn 1 : warn 2"
2 at -e line 1.
Terminating on signal SIGINT(2)

Version information

C:\>perl -MWin32::GUI -e "die Win32::GUI->VERSION"
1.05 at -e line 1.

C:\>perl -v

This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 25 registered patches, see perl -V for more detail)

Copyright 1987-2006, Larry Wall

Binary build 817 [257965] provided by ActiveState http://www.ActiveState.com
Built Mar 20 2006 17:54:25

Discussion

  • Robert May
    Robert May
    2007-01-09

    Logged In: YES
    user_id=674651
    Originator: NO

    What operating system are you seeing this on. I can reproduce it with Win98, but not with Win2k (AS Perl 5.8.8, build 819). Can you also post the output of your perl -V

     
  • Robert May
    Robert May
    2007-01-09

    • assigned_to: nobody --> robertemay
     
  • Brad Bowman
    Brad Bowman
    2007-01-09

    perl -V output

     
    Attachments
  • Brad Bowman
    Brad Bowman
    2007-01-09

    Logged In: YES
    user_id=1527744
    Originator: YES

    I'm using WinXP Pro SP2 (one machine under VMware and one over VNC)
    with AS Perl 5.8.8 build 817. Perl -V output attached

    File Added: perl-V

     
  • Robert May
    Robert May
    2007-01-13

    Logged In: YES
    user_id=674651
    Originator: NO

    OK, this looks like a bug in perl itself. Your perl -V contains this line:
    27527 win32_async_check() can loop indefinitely

    Only the fix applied by that patch appears incomplete to me.

    I simplified the problem to a non-forked one; can you confirm

    (1) that the following also hangs for you
    perl -MWin32::GUI -e "Win32::GUI::GetOpenFileName(); alarm(0); sleep(1)"

    (2) that in both cases CPU usage is at 100% during the hang.

    If you need a work around, then use Win32::Sleep(1000) instead of sleep(1) - I don't completely understand why Win32::GUI::GetOpenFileName() is causing this, so I can't offer anything cleverer. I can, however, make it all behave correctly by fixing up the perl core, so I'll submit a patch to the perl porters, and see if they can shed any more light.

    I also don't understand why I can't see the problem on Win2K.

    Regards,
    Rob.

     
  • Brad Bowman
    Brad Bowman
    2007-01-14

    Logged In: YES
    user_id=1527744
    Originator: YES

    > I simplified the problem to a non-forked one; can you confirm
    >
    > (1) that the following also hangs for you
    > perl -MWin32::GUI -e "Win32::GUI::GetOpenFileName(); alarm(0); sleep(1)"

    Yes, this also hangs.

    > (2) that in both cases CPU usage is at 100% during the hang.

    Yes.

    > - I don't completely understand why Win32::GUI::GetOpenFileName() is
    > causing this, so I can't offer anything cleverer.

    The same thing seems to happen with a MessageBox, fwiw:

    perl -MWin32::GUI -le "Win32::GUI::Window->new->MessageBox(hi);alarm(0)
    ;sleep(0)"

    I encountered another hang which seems similar but doesn't (directly)
    use sleep:

    perl -MWin32::GUI -le "Win32::GUI::Window->new->MessageBox(hi);warn 1;fork or die 2; system(q{echo 3}); die 4"
    1 at -e line 1.
    2 at -e line 1.
    3
    Terminating on signal SIGINT(2)

    Again, 100% cpu and the "4" never is run.

    Thanks for investigating and fixing this,

    Brad

     
  • Robert May
    Robert May
    2007-01-17

    • status: open --> closed-fixed
     
  • Robert May
    Robert May
    2007-01-17

    Logged In: YES
    user_id=674651
    Originator: NO

    Thanks for the feedback. It enabled me to find this one-liner that doesn't need Win32::GUI:
    perl -MWin32 -e "Win32::MsgBox q(); alarm 0; sleep 1;"

    It's confirmed as a core perl bug (and not a Win32::GUI one (for once!). You can find the thread and the patch here:
    http://beta.nntp.perl.org/group/perl.perl5.porters/2007/01/msg119921.html

    I'm going to close this item.

    Regards,
    Rob.