Skip Menu |
 

This queue is for tickets about the File-Slurp CPAN distribution.

Report information
The Basics
Id: 77276
Status: open
Priority: 0/
Queue: File-Slurp

People
Owner: Nobody in particular
Requestors: FRAZER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 9999.19
Fixed in: (no value)



Subject: segfault when called in wrong context
Download (untitled) / with headers
text/plain 630b
When read_file is called and used with split, it causes a segmentation fault. Here is an example: perl -MFile::Slurp -le 'split /\n/, File::Slurp::read_file("/home/me/.bashrc")' Segmentation fault (core dumped) I traced it through the debugger and it was on line 116 (if ( !ref $file_name && -e $file_name && -s _ > 0 && -s _ < $max_fast_slurp_size && !%{$opts} && !wantarray ) {). I think it died when it got to "-s _" on that line. It works fine when called like this, so I think it might be the context in which it is called: perl -MFile::Slurp -le 'my $f = File::Slurp::read_file("/home/frazer/.bashrc"); split /\n/, $f;'
Download (untitled) / with headers
text/plain 768b
On Fri May 18 09:20:51 2012, FRAZER wrote: Show quoted text
> When read_file is called and used with split, it causes a segmentation > fault. Here is an example: > perl -MFile::Slurp -le 'split /\n/, > File::Slurp::read_file("/home/me/.bashrc")' > Segmentation fault (core dumped) > > I traced it through the debugger and it was on line 116 (if ( !ref > $file_name && -e $file_name && -s _ > 0 && -s _ < $max_fast_slurp_size > && !%{$opts} && !wantarray ) {). I think it died when it got to "-s _" > on that line. > > It works fine when called like this, so I think it might be the context > in which it is called: > perl -MFile::Slurp -le 'my $f = > File::Slurp::read_file("/home/frazer/.bashrc"); split /\n/, $f;'
I don’t get that crash. What version of perl are you using?
I meant to come back and update with these details. I am on Solaris 9 using perl 5.14.2. I have tried with perl 5.8.6 on the same server and it does not have the same problem. On Fri May 18 12:47:46 2012, SPROUT wrote: Show quoted text
> On Fri May 18 09:20:51 2012, FRAZER wrote:
> > When read_file is called and used with split, it causes a segmentation > > fault. Here is an example: > > perl -MFile::Slurp -le 'split /\n/, > > File::Slurp::read_file("/home/me/.bashrc")' > > Segmentation fault (core dumped) > > > > I traced it through the debugger and it was on line 116 (if ( !ref > > $file_name && -e $file_name && -s _ > 0 && -s _ < $max_fast_slurp_size > > && !%{$opts} && !wantarray ) {). I think it died when it got to "-s _" > > on that line. > > > > It works fine when called like this, so I think it might be the context > > in which it is called: > > perl -MFile::Slurp -le 'my $f = > > File::Slurp::read_file("/home/frazer/.bashrc"); split /\n/, $f;'
> > I don’t get that crash. What version of perl are you using?
Download (untitled) / with headers
text/plain 1.4k
On Fri May 18 13:17:25 2012, FRAZER wrote: Show quoted text
> I meant to come back and update with these details. I am on Solaris 9 > using perl 5.14.2. I have tried with perl 5.8.6 on the same server and > it does not have the same problem.
What is the output of perl -v? Is it possible to get a C backtrace? If your perl was compiled with gcc you should be able to do this: $ gdb --args perl -e '...' Show quoted text
gdb> run
And, when it complains about memory violations: Show quoted text
gdb> bt
I can’t reproduce this in 5.10.1 (threaded), 5.14.2 (threaded), or 5.15.9 (unthreaded). Show quoted text
> > On Fri May 18 12:47:46 2012, SPROUT wrote:
> > On Fri May 18 09:20:51 2012, FRAZER wrote:
> > > When read_file is called and used with split, it causes a segmentation > > > fault. Here is an example: > > > perl -MFile::Slurp -le 'split /\n/, > > > File::Slurp::read_file("/home/me/.bashrc")' > > > Segmentation fault (core dumped) > > > > > > I traced it through the debugger and it was on line 116 (if ( !ref > > > $file_name && -e $file_name && -s _ > 0 && -s _ < $max_fast_slurp_size > > > && !%{$opts} && !wantarray ) {). I think it died when it got to "-s _" > > > on that line. > > > > > > It works fine when called like this, so I think it might be the context > > > in which it is called: > > > perl -MFile::Slurp -le 'my $f = > > > File::Slurp::read_file("/home/frazer/.bashrc"); split /\n/, $f;'
> > > > I don’t get that crash. What version of perl are you using?
> >
Download (untitled) / with headers
text/plain 418b
I am experiencing the same issue (Segmentation fault: 11 (core dumped)) with perl 5.12.0 on freebsd8.2 though I am calling read_file in scalar context. If I change the "-s _" to "-s $file_name" on lines 116 and 117 it then works. I do not seem to have the problem on other perls on that machine (5.10.1, 5.15.8, 5.17.2). I attached perl -V and also the output of Devel::Trace where I consistently have this problem.
Subject: perl-V-5.12.0-freebsd.txt
Summary of my perl5 (revision 5 version 12 subversion 0) configuration: Platform: osname=freebsd, osvers=8.2-release, archname=i386-freebsd uname='freebsd freebsd82.raptor.local 8.2-release freebsd 8.2-release #0: fri feb 18 02:24:46 utc 2011 root@almeida.cse.buffalo.edu:usrobjusrsrcsysgeneric i386 ' config_args='-de -Dprefix=/home/rando/perl5/perlbrew/perls/perl-5.12.0' hint=recommended, useposix=true, d_sigaction=define 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 ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include', optimize='-O', cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.2.1 20070719 [FreeBSD]', 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 ='-Wl,-E -fstack-protector -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lm -lcrypt -lutil -lc perllibs=-lm -lcrypt -lutil -lc libc=, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Built under freebsd Compiled at Dec 6 2012 09:16:24 %ENV: PERLBREW_BASHRC_VERSION="0.39" PERLBREW_HOME="/home/rando/.perlbrew" PERLBREW_MANPATH="/home/rando/perl5/perlbrew/perls/perl-5.12.0/man" PERLBREW_PATH="/home/rando/perl5/perlbrew/bin:/home/rando/perl5/perlbrew/perls/perl-5.12.0/bin" PERLBREW_PERL="perl-5.12.0" PERLBREW_ROOT="/home/rando/perl5/perlbrew" PERLBREW_VERSION="0.39" @INC: /home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/i386-freebsd /home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0 /home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/5.12.0/i386-freebsd /home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/5.12.0 .
Subject: slurp-segfault-trace.txt
>> -e:1: Parse::CPAN::Packages->new(filename => "t/02packages.details.txt")->_slurp_details >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:10: my $class = shift; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:11: $class = Scalar::Util::blessed($class) || $class; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:12: return $class->Moose::Object::new(@_) >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:14: my $params = >> lib/Parse/CPAN/Packages.pm:23: my ( $class, @args ) = @_; >> lib/Parse/CPAN/Packages.pm:24: return {@args} if @args > 1; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:17: my $instance = bless {} => $class; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:19: if (exists $params->{'data'}) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:26: my $default = $defaults->[0]->($instance); >> lib/Parse/CPAN/Packages.pm:16: has 'data' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:27: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:27: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:30: $instance->{"data"} = $default; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:33: if (exists $params->{'details'}) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:40: my $default = $defaults->[1]->($instance); >> lib/Parse/CPAN/Packages.pm:15: has 'details' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:41: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:41: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:44: $instance->{"details"} = $default; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:47: if (exists $params->{'dists'}) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:54: my $default = $defaults->[2]->($instance); >> lib/Parse/CPAN/Packages.pm:17: has 'dists' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:55: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:55: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:58: $instance->{"dists"} = $default; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:61: if (exists $params->{'filename'}) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:62: if (! (( do { ( do { ( do { defined($params->{'filename'}) } ) && !ref($params->{'filename'}) } ) && (ref(\$params->{'filename'}) eq "SCALAR" || ref(\(my $val = $params->{'filename'})) eq "SCALAR") } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:62: if (! (( do { ( do { ( do { defined($params->{'filename'}) } ) && !ref($params->{'filename'}) } ) && (ref(\$params->{'filename'}) eq "SCALAR" || ref(\(my $val = $params->{'filename'})) eq "SCALAR") } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:62: if (! (( do { ( do { ( do { defined($params->{'filename'}) } ) && !ref($params->{'filename'}) } ) && (ref(\$params->{'filename'}) eq "SCALAR" || ref(\(my $val = $params->{'filename'})) eq "SCALAR") } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:62: if (! (( do { ( do { ( do { defined($params->{'filename'}) } ) && !ref($params->{'filename'}) } ) && (ref(\$params->{'filename'}) eq "SCALAR" || ref(\(my $val = $params->{'filename'})) eq "SCALAR") } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:65: $instance->{"filename"} = $params->{'filename'}; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:68: if (exists $params->{'latestdists'}) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:75: my $default = $defaults->[4]->($instance); >> lib/Parse/CPAN/Packages.pm:18: has 'latestdists' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:76: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:76: if (! (( do { ref($default) eq "HASH" } ))) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:79: $instance->{"latestdists"} = $default; >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:82: if (exists $params->{'mirror_dir'}) { >> (eval 253)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:88: $instance->Parse::CPAN::Packages::BUILD($params); >> lib/Parse/CPAN/Packages.pm:29: my $self = shift; >> lib/Parse/CPAN/Packages.pm:30: my $filename = $self->filename; >> (eval 245)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:6: if (@_ > 1) { >> (eval 245)[/home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Eval/Closure.pm:125]:12: return $_[0]->{"filename"}; >> lib/Parse/CPAN/Packages.pm:33: $self->parse( $filename ) if $filename; >> lib/Parse/CPAN/Packages.pm:71: my ( $self, $filename ) = @_; >> lib/Parse/CPAN/Packages.pm:74: my @details = split "\n", $self->_slurp_details( $filename ); >> lib/Parse/CPAN/Packages.pm:48: my ( $self, $filename ) = @_; >> lib/Parse/CPAN/Packages.pm:49: $filename ||= '02packages.details.txt.gz'; >> lib/Parse/CPAN/Packages.pm:51: return $filename if $filename =~ /Description:/; >> lib/Parse/CPAN/Packages.pm:52: return Compress::Zlib::memGunzip( $filename ) if $filename =~ /^\037\213/; >> lib/Parse/CPAN/Packages.pm:54: my @read_params = ( $filename ); >> lib/Parse/CPAN/Packages.pm:55: push @read_params, ( binmode => ':raw' ) if $filename =~ /\.gz/; >> lib/Parse/CPAN/Packages.pm:57: print STDERR READ_PARAMS => @read_params, "\n"; READ_PARAMSt/02packages.details.txt >> lib/Parse/CPAN/Packages.pm:58: my $data = read_file( @read_params ); >> /home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/File/Slurp.pm:109: my $file_name = shift ; >> /home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/File/Slurp.pm:110: my $opts = ( ref $_[0] eq 'HASH' ) ? shift : { @_ } ; >> /home/rando/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/File/Slurp.pm:116: if ( !ref $file_name && -e $file_name && -s _ > 0 && Segmentation fault: 11 (core dumped)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.