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

Re: [perl #41647] Perl 5.8 crashes while syntax-checking six-linesof code -- Windows only

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
February 28, 2007 16:56
Subject:
Re: [perl #41647] Perl 5.8 crashes while syntax-checking six-linesof code -- Windows only
Message ID:
45E6249A.5010109@pobox.com
Eric Promislow (via RT) wrote:
> Running `{w,}perl -c[wT]*' on this six-line file crashes
> Perl on Windows:
> 
> sub getStuff {
>    my $str = $nodelist->{'att'}->{'type'};
>    if (1) {
>      use Devel::D or die;
>    }
> }
> 
> 
> You can enter this code interactively at the dos prompt --
> once you type the line containing the first "}" Perl will
> crash at that point.  I need both the 'sub' and the
> assignment -- pulling either out prevents the crash.
> Also changing "getStuff" to "f" prevented the crash.

We need more information about what you mean by "crash".  Do you mean causes
a general protection fault?  Do you mean doesn't compile?  Do you get a
syntax error?  Can you show us the exact error?

Here's the error I get on OS X:

$ perl -cw
 sub getStuff {
    my $str = $nodelist->{'att'}->{'type'};
    if (1) {
      use Devel::D or die;
    }
 }
syntax error at - line 4, near "use Devel::D or"
syntax error at - line 6, near "}"
- had compilation errors.

Note that "use Module or something()" is not legal syntax.  Also note that
"use" happens at compile time, it happens as the code is being parsed, not
when the subroutine is run.  Putting it inside an if statement or even
inside a subroutine has no effect.  To get the effect you want would be
something more like:

    eval { require Devel::D;  Devel::D->import } or die;

Or just:

    require Devel::D;  Devel::D->import;


> Expected behavior:
> Perl runs this with -c on, and possibly '-w' and '-T'
> as well.  It should given an error message reporting
> that it can't load the module Devel::D.  It should give
> an error message if strict is on, and $nodelist isn't
> defined.
> 
> The crash happens with Active Perl 819, but not
> Active Perl 5.6.1 638, nor perl build 522.



Thread Previous | 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