This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
leave_adjust_stacks(): avoid accessing random tmps
There was some code in leave_adjust_stacks() that checked whether the
current arg sv being processed was the same SV as the first SvTEMP
above the 'cut' on the tmps stack. If there was nothing above the cut,
it was actually comparing against whatever garbage was 1 slot above the
current PL_tmps_ix. This was almost always harmless (but of course wrong);
the only symptom was an occasional smoke failure in t/re/pat_re_eval_thr.t,
due to this:
local our $s = "abc";
my $qr = qr/^(?{1})$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s/;
where a qr// with a code blocks acts like
my $qr = sub : lvalue { .....; }->()
to make closures happen correctly. The lvalue return from the anon sub was
triggering this because the address of $s was in one of the unused slots
above PL_tmp_ix.
I couldn't get it to fail in a simple test case.
At the same time, I moved a SvREFCNT_inc() inside a check for
!SvIMMORTAL(sv) since there's no need to do it for PL_sv_undef etc.