develooper Front page | perl.perl5.porters | Postings from May 2004

[perl #29708] Problem with autouse (causing Perl to crash)

Thread Next
From:
Steve Hay
Date:
May 19, 2004 05:39
Subject:
[perl #29708] Problem with autouse (causing Perl to crash)
Message ID:
rt-3.0.9-29708-87779.17.2965328304932@perl.org
# New Ticket Created by  Steve Hay 
# Please include the string:  [perl #29708]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=29708 >


This is a bug report for perl from steve.hay@uk.radan.com,
generated with the help of perlbug 1.35 running under perl v5.8.4.


-----------------------------------------------------------------
[Please enter your report here]

I have a problem using the "autouse" pragma which is causing perl 
(5.8.4) to crash.  I've reduced it to the following two modules:

Foo.pm
======
package Foo;
use Exporter qw();
our @EXPORT = qw(foo);
our @ISA = qw(Exporter);
sub foo() { require Bar; Bar::bar() }
1;

Bar.pm
======
package Bar;
use autouse 'Foo' => qw(foo());
my $done = 0;
sub bar() {
    return if $done;
    $done = 1;
    print "calling foo() once ...\n";
    foo();
    print "... ok\n";
    print "calling foo() again ...\n";
    foo();
    print "... ok\n";
}
1;

Running:

    >perl -MBar -MFoo -we "Foo::foo()"

produces the output:

    calling foo() once ...
    ... ok
    calling foo() again ...

and then perl.exe crashes with an Access Violation.  Here's a stacktrace 
from the crash (under perl-5.8.4):

Perl_pp_entersub() line 2912 + 2 bytes
Perl_runops_standard() line 24 + 3 bytes
S_run_body(long 1) line 1924
perl_run(interpreter * 0x00223c40) line 1840 + 9 bytes
RunPerl(int 5, char * * 0x00223c00, char * * 0x00222ba8) line 202 + 6 bytes
PERL! mainCRTStartup + 227 bytes
KERNEL32! 77e814c7()

The same command-line runs fine, producing the second "... ok" line, 
under the "-d" debugger (e.g. perl -d:ptkdb -MBar -MFoo -we "Foo::foo()").

I can fix it by reversing the order in which the Foo and Bar modules are 
loaded:

    >perl -MFoo -MBar -we "Foo::foo()"

or by not loading Bar initially:

    >perl -MFoo -we "Foo::foo()"

or by changing the following line within Bar.pm:

    use autouse 'Foo' => qw(foo());

to either:

    use autouse 'Foo' => qw(foo);

(!!!) or simply:

    use Foo;

(understandable).


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.4:

Configured by steveh at Mon Apr 26 14:01:56 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-perlio
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_DEBUGGING_MSTATS 
-DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=4
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  
-libpath:"C:\perl5\lib\CORE"  -machine:x86'
    libpth=C:\PROGRA~1\MICROS~2\VC98\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  
netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib 
odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  
version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf  -libpath:"C:\perl5\lib\CORE"  -machine:x86'

Locally applied patches:
    

---
@INC for perl v5.8.4:
    C:/perl5/lib
    C:/perl5/site/lib
    .

---
Environment for perl v5.8.4:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\perl5\bin
    PERL_BADLANG (unset)
    SHELL (unset)




------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only.  If you have received this message in error or there are any problems, please notify the sender immediately.  The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden.  Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd.  The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.


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