On Sun, Jul 17, 2005 at 02:27:35PM -0700, Michael G Schwern wrote: > On Sun, Jul 17, 2005 at 09:41:58PM +0100, Dave Mitchell wrote: > > +# [perl #36521] goto &foo in warn handler could defeat recursion avoider > > + > > +{ > > + my $r = runperl( > > + stderr => 1, > > + prog => 'my $d; my $w = sub { return if $d++; warn q(bar)}; > > local $SIG{__WARN__} = sub { goto &$w; }; warn q(foo);' > > + ); > > + like($r, qr/bar/, "goto &foo in warn"); > > This program does not segfault, it does nothing. > > 0 ~$ perl5.8.6 -wle 'my $d; my $w = sub { return if $d++; warn q(bar)}; local > $SIG{__WARN__} = sub { goto &$w; }; warn q(foo);' > 0 ~$
That's the idea. In fixed bleed, it prints a warning: $ ./perl -wle 'my $d; my $w = sub { return if $d++; warn q(bar)}; local $SIG{__WARN__} = sub { goto &$w; }; warn q(foo);' bar at -e line 1. $ The test minimally detects bad behaviour while avoiding runaway recursion and segfault. -- "Emacs isn't a bad OS once you get used to it. It just lacks a decent editor."