develooper Front page | perl.perl5.porters | Postings from March 2006

[perl #18489] perl 5.8.0 segfaults

From:
Steve Peters via RT
Date:
March 29, 2006 08:52
Subject:
[perl #18489] perl 5.8.0 segfaults
Message ID:
rt-3.0.11-18489-131643.17.0952298952592@perl.org
> [andk - Tue Nov 19 00:14:59 2002]:
> 
> >>>>> On 18 Nov 2002 22:30:21 -0000, Rune Froysa (via RT)
> <perlbug@perl.org> said:
> 
>   > # New Ticket Created by  Rune Froysa
>   > # Please include the string:  [perl #18489]
>   > # in the subject line of all future correspondence about this
> issue.
>   > # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=18489 >
> 
> 
>   > This is a bug report for perl from runefro@ulrik.uio.no,
>   > generated with the help of perlbug 1.34 running under perl v5.8.0.
> 
> 
>   > -----------------------------------------------------------------
>   > [Please enter your report here]
> 
>   > Running the below program results in:
> 
>   >   Attempt to free unreferenced scalar at ../perl-bug-segfault line
> 10.
>   >   Segmentation fault
> 
>   > Uncommenting the find line, and commenting the @files declaration
>   > segfaults with no message.
> 
>   > #!/usr/bin/perl
>   > use File::Find;
> 
>   > sub wanted{
>   >     push(@files, $File::Find::name);
>   > }
> 
>   > #find(\&wanted, '.');
>   > @files = ('foo', 'ar', 'gazonk');
>   > for my $path (sort(@files)) {
>   >     $t = '\0\A';
>   >     $t =~ s/\\([nA])/&convpart($`, $1)/eg;
>   > }
> 
>   > sub convpart {
>   >     my ($dir, $fname) = ( 'foo' =~ m,(.*/)([^/]+)$,);
>   >     opendir(DIR, $dir);
>   >     @files = sort(grep {/^$fname/} readdir(DIR));
>   >     closedir(DIR);
>   > }
> 
> SEGV confirmed for shorter test:
> 
> @files = (1,2);
> for (sort @files) {
>     @files = ();
> }
> 

The problem segfault has sometime in the past been replaced with a
troublesome panic.  Better, but still a problem.

steve@kirk:~/smoke/perl-current$ ./perl rt_18489.pl
Use of freed value in iteration at rt_18489.pl line 5.

steve@kirk:~/smoke/perl-current$ cat rt_18489.pl
#!perl -w

@files = (1,2);
for (sort @files) {
    @files = ();
}




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About