develooper Front page | perl.perl5.porters | Postings from June 2008

[perl #22977] Bug in format/write

Thread Previous | Thread Next
From:
Bram via RT
Date:
June 27, 2008 19:32
Subject:
[perl #22977] Bug in format/write
Message ID:
rt-3.6.HEAD-18542-1214593447-649.22977-15-0@perl.org
On Mon Jul 14 15:15:03 2003, davem wrote:
> On Mon, Jul 14, 2003 at 05:37:42AM -0000, Ruediger Schopper wrote:
> > I belive, that we've found a bug in perl. We discovered it when
> changing from
> > perl-5.4.4 to perl-5.8.0, where we got strange results with
> > write in a program we heavily used without problems.
> 
> The bug can be reduced to the simpler case:
> 
>     sub f ($); # Comment out to get right result!
>     sub f ($) {
> 	my $test = $_[0];
> 	write;
> 	format STDOUT =
>     @<<<<<<<
>     $test
>     .
>     }
>     f(1);
>     f(2);
> 
> It's due to there being multiple CVs associated with f due to to the
> forward declaration, and to newATTRSUB() copying the contents of the
> second CV to the first.  This causes any nested subs to have 
CvOUTSIDE
> pointing to the wrong CV. A call to pad_fixup_inner_anons() fixes up
> any
> nested anon subs, but nested formats aren't fixed up.
> 
> Since I'm currently working on trying to get sub declarations
> to take effect at the start of a sub rather than at the end (eg
> sub f($) { f(1) }), I'll see if I can work in a fix for this at the
> same time.
> 

It appears that things got worse for 5.10.0/blead...

perl-5.8.8 rt-22977.pl
1
1

(Instead of 1 2)

perl-5.9.0 rt-22977.pl
Segmentation fault

perl-5.10.0 rt-22977.pl
Segmentation fault

perl-blead rt-22977.pl
Segmentation fault


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