On Wed, May 04, 2005 at 03:28:47PM +0100, Dave Mitchell wrote: > On Wed, May 04, 2005 at 10:37:43AM -0000, Brendan O'Dea wrote: > > Segfault in the following code: > > > > #!/usr/bin/perl > > > > for ($_ = 1; $_ < 3; $_++) > > { > > AGAIN: > > if ($_ == 1) { next } > > if ($_ == 2) { $_ = 3; goto AGAIN } > > } > > Fixed by the change below. next (and redo) didn't retore the old > PL_curcop, so on next loop entry, the oldcop stored in the context block > was the wrong one, which then confused goto. > > This is demonstrated by the following code > > #!/usr/bin/perl -w > for ($_=1; (($_ == 2 && die), $_<3); $_++) { > next if $_ == 1; > } > > $ perl592 /tmp/p > Died at /tmp/p line 3. > $ ./fixedperl /tmp/p > Died at /tmp/p line 2. > $ >
I'm guessing this is an unintentional side effect, but this fix also took care of the long-standing issue of redo's within a for loop that I tried to get some discussion about last week (RT #2049). Steve Peters [EMAIL PROTECTED]