What happened was that a constant was freed, the pad released but
the pad slot still held the SV, when pad slot was reallocated
to be a target for a stringify, it did a sv_setpv on the target
and the original SV was wiped out. When this SV was later on
to new places using the constant, they got the wrong value.
By replacing pad_free with pad_swipe for these cases, we
won't have such a problem. (pad_swipe also removes the
pointer to the original SV).
p4raw-id: //depot/perl@18820
case OP_CONST:
SvREFCNT_dec(cSVOPo->op_sv);
cSVOPo->op_sv = Nullsv;
+#ifdef USE_ITHREADS
+ /** Bug #15654
+ Even if op_clear does a pad_free for the target of the op,
+ pad_free doesn't actually remove the sv that exists in the bad
+ instead it lives on. This results in that it could be reused as
+ a target later on when the pad was reallocated.
+ **/
+ if(o->op_targ) {
+ pad_swipe(o->op_targ,1);
+ o->op_targ = 0;
+ }
+#endif
break;
case OP_GOTO:
case OP_NEXT: