Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Reality checking a win32 perl bug

by bsb (Priest)
on May 16, 2006 at 02:36 UTC ( [id://549649]=perlquestion: print w/replies, xml ) Need Help??

bsb has asked for the wisdom of the Perl Monks concerning the following question:

update perlbugged and resolved:
[perl #39145] [RESOLVED] win32, @_ and fork crashing in dounwind

I'd just want to check that what seems to be to be a bug occurs for others and isn't already perlbugged. I'll perlbug it once confirmed. On Windows 2000 with ActivePerl 5.8.8, the following produces an application error:

perl -e "sub { @_ = sub {@_}->(@_); fork ? die 5 : die 6 }->(2)"

Screenshot

Brad
Update: It can be simpler still

perl -e "sub { @_ = 3; fork ? die 5 : die 6 }->()"

Replies are listed 'Best First'.
Re: Reality checking a win32 perl bug
by xdg (Monsignor) on May 16, 2006 at 11:11 UTC

    Confirmed on WinXP VanillaPerl 5.8.8. Prints the two lines then has the application error dialog box.

    > perl -e "sub { @_ = 3; fork ? die 5 : die 6 }->()" 5 at -e line 1. 6 at -e line 1. # App Error here # > perl --version This is perl, v5.8.8 built for MSWin32-x86-multi-thread

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re: Reality checking a win32 perl bug
by jesuashok (Curate) on May 16, 2006 at 02:58 UTC
    Hi

    even I got the same error on windows 2000.

    C:\Documents and Settings\antony\Desktop>perl -e "sub { @_ = sub {@_}- +>(@_); for k ? die 5 : die 6 }->(2)" 5 at -e line 1. 6 at -e line 1.

    In perl bug lists, there are lot of bugs registered with regard to Fork
    You can check the following also Tainted fork crash on Win32

    "Keep pouring your ideas"
Re: Reality checking a win32 perl bug
by ady (Deacon) on May 16, 2006 at 04:41 UTC
    Microsoft Windows XP [version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Perl\Test\WEB\Mechanize>perl -e "sub { @_ = 3; fork ? die 5 : die 6 + }->()" 6 at -e line 1. 5 at -e line 1. Exception: AppName: perl.exe AppVer: 5.8.7.813 ModName: perl58.dll ModVer: 5.8.7.813 Offset: 0003706e C:\Perl\Test\WEB\Mechanize>perl -version This is perl, v5.8.7 built for MSWin32-x86-multi-thread (with 7 registered patches, see perl -V for more detail)
    Best regards,
    Allan
Re: Reality checking a win32 perl bug
by blazar (Canon) on May 16, 2006 at 10:26 UTC

    Wild guess: in both your examples you die in any case. This means that the program terminates with an exit value that is not null, i.e. technically, it fails. That is, it may not be an error, but exactly what is supposed to happen. Have you tried s/die/print/?

    What are you really trying to achieve? What did you expect to happen?

    perl -e "sub { @_ = sub {@_}->(@_); fork ? die 5 : die 6 }->(2)"

    Hmmm... here you dereference a subref passing in 2 as an arg. Then you pass the whole argument list, that is (2), to another anonymous sub that will just return its arguments, and assign that back to the argument list, which is not changed after all. Having done all this you don't do anything with the input value, but simply fork and die both if you're the "forked" process or the parent one - or if the fork failed.

    perl -e "sub { @_ = 3; fork ? die 5 : die 6 }->()"

    Less byzantine, but still @_ = 3; does nothing, really.

      The point is not that the program fails, but that it fails in a way that pops up the Windows Application Error dialog box -- i.e. perl.exe fails due to some sort of memory access error, which is different than the script failing. That's the bug. (Same with Tainted fork crash on Win32.)

      It seems to be triggered by assigning to @_ in a fork. It's not the die or the anonymous sub. Even localizing it doesn't help. These variations crash perl.exe, too:

      > perl -e "sub foo { @_ = (1); fork ? exit : exit } foo" > perl -e "sub foo { local @_ = (1); fork ? exit : exit } foo"

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://549649]
Approved by Moriarty
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-29 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found