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

Re: odd (or not so odd?) segmentation fault in 5.8.0

Thread Previous | Thread Next
From:
Enache Adrian
Date:
February 16, 2003 16:20
Subject:
Re: odd (or not so odd?) segmentation fault in 5.8.0
Message ID:
20030217001459.GA1031@ratsnest.hole
On Sun, Feb 16, 2003 at 01:44:14PM -0500, Mark Mielke wrote:
> > > > Better try to rewrite your code to something like this ?
> > > > perl -e 'sub TIESCALAR {bless[]} \
> > > > 	 sub FETCH {my $a = tied $_[0]; untie $$a; $$a=1} \
> > > > 	 tie($a,__PACKAGE__);print $a'

My script was just flawed. (this reversed tied there ..).

> > That really becomes interesting.
> > $ perl5.8.0 -e 'sub TIESCALAR { bless[] } sub FETCH { untie $a; print $a; "FETCH\n" }; tie $a, __PACKAGE__; print $a, $a, $a'
> > FETCH
> > FETCH
> > FETCH
> > FETCH
> > FETCH
> > $ perl5.6.1 -e 'sub TIESCALAR { bless[] } sub FETCH { untie $a; print $a; "FETCH\n" }; tie $a, __PACKAGE__; print $a, $a, $a'
> > FETCH
> > FETCH
> > FETCH

more curious examples:

$ perl5.6.1 -e '$,=" ";$a = 1; { package P; sub TIESCALAR {bless[]} \
    sub FETCH {"($main::a)"} } tie $a, P; print "$a $a $a $a $a $a\n"'
((1)) (((1))) ((((1)))) (((((1))))) ((((((1)))))) (((((((1)))))))

$ perl5.8.0 -e '$,=" ";$a = 1; { package P; sub TIESCALAR {bless[]} \
    sub FETCH {"($main::a)"} } tie $a, P; print "$a $a $a $a $a $a\n"'
(1) ((1)) (((1))) ((((1)))) (((((1))))) ((((((1))))))

but:

$ perl5.8.0 -e '$,=" ";$a = 1; { package P; sub TIESCALAR {bless[]} \
    sub FETCH {"($main::a)"} } tie $a, P; print $a,"$a $a $a $a $a\n"'
((((((1)))))) (1) ((1)) (((1))) ((((1)))) (((((1)))))

$ perl5.8.0 -e '$,=" ";$a = 1; { package P; sub TIESCALAR {bless[]} \
    sub FETCH {"($main::a)"} } tie $a, P; print $a,"$a",$a,"$a $a $a\n"'
(((((1))))) (1) ((((((1)))))) ((1)) (((1))) ((((1))))

(perl 5.003 & bleedperl work just like 5.8.0)

I expected from it to:

1. print '(1) (1) (1)' ... 
2. go in some crazy loop.

Adi

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