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

Weird $@, require, and constants segfault

Thread Next
From:
Alex Vandiver
Date:
February 26, 2003 06:00
Subject:
Weird $@, require, and constants segfault
Message ID:
1046268023.27925.287.camel@supox
Heya,
  This is a look at the bug that originally arose when one attempted to
"use lib $Config{moose}"  I've narrowed it down to failing on slightly
simpler test cases (files are at bottom of email):

$ perl5.9 -I. -we 'use Config; use Crash $Config{crash};'
Scalar value @_[1] better written as $_[1] at Crash.pm line 4.
Use of uninitialized value in null operation at -e line 1.
Undefined subroutine &main:: called at -e line 1.
END failed--call queue aborted at -e line 2.
Callback called exit at -e line 2.
Segmentation fault

  However, at this point I'm stymied.  A few points which I've found
out:
  - The "line 2" it refers to is in Moose.pm

  - "warnings" is not the only module in Moose that will cause a
segfault, but it's spotty.  To pick a few: DB, subs, and strict don't
cause segfaults, while CGI, Benchmark, Carp, Safe, and threads do.

  - Changing "use warnings" to "require warnings" results in:
$ perl5.9 -I. -we 'use Config; use Crash $Config{crash};'
Scalar value @_[1] better written as $_[1] at Crash.pm line 4.
Use of uninitialized value in null operation at -e line 1.
Undefined subroutine &main:: called at -e line 1.
END failed--call queue aborted at -e line 130.
Callback called exit at -e line 130.
Attempt to free unreferenced scalar at -e line 130.
BEGIN failed--compilation aborted at -e line 1.

  - The read-only value must be the first in the for loop to cause a
segfault

  - Taking out the "local $@" line stops the segmentation fault, but
still yields a lot of weird errors:
Scalar value @_[1] better written as $_[1] at Crash.pm line 4.
%Config::Config is read-only
Compilation failed in require at Moose.pm line 2.
END failed--call queue aborted at Moose.pm line 130.
Compilation failed in require at Crash.pm line 5.
END failed--call queue aborted at -e line 2.
Callback called exit at -e line 2.
BEGIN failed--compilation aborted at -e line 1.

Bletch.  I'm in over my head.
 - Alex

## Files to reproduce the bug:
## File: Crash.pm
package Crash;
sub import {
  local $@;
  for (@_[1]) {
    require Moose;
  }
}
1;

## File: Moose.pm
package Moose;
use warnings;
1;
__END__

Summary of my perl5 (revision 5.0 version 9 subversion 0 patch 18782) configuration:
  Platform:
    osname=linux, osvers=2.4.18, archname=i686-linux
    uname='linux supox.mit.edu 2.4.18 #1 wed apr 3 14:26:03 est 2002 i686 unknown '
    config_args='-de -Dusedevel'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O3',
    cppflags='-fno-strict-aliasing -I/usr/include/gdbm'
    ccversion='', gccversion='3.1 20020205 (Red Hat Linux Rawhide 3.1-0.21)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lutil -lrt
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil -lrt
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.4'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


-- 
Networking -- only one letter away from not working.


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