From 04698ff67968faa57a46c12d31e17c17baf08876 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 27 Nov 2010 06:22:24 -0800 Subject: [perl #79178] STORE/FETCH of tie()d hash get stringified key This bug has been present in non-threaded builds for a long time. Change 38bb37b9aa introduced it to threaded builds. $hash{...} makes its operand a shared-PV scalar if it is an OP_CONST. But \"foo" is also an OP_CONST, as is anything generated with use constant. This is the sort of thing that results: $ perl5.8.5 -MO=Concise -e '$a{\"foo"}' 7 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 6 <2> helem vK/2 ->7 4 <1> rv2hv sKR/1 ->5 3 <$> gv(*a) s ->4 5 <$> const(PVIV "SCALAR(0x81b378)") s ->6 -e syntax OK (My 5.8.5 installation is non-threaded.) See the "SCALAR(0x81b378)" in there? So this commit skips that optimisation if the key is ROK or if it is a PVMG or higher. --- op.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'op.c') diff --git a/op.c b/op.c index 53641c7a8d..4c3c876662 100644 --- a/op.c +++ b/op.c @@ -9661,7 +9661,8 @@ Perl_rpeep(pTHX_ register OP *o) /* Make the CONST have a shared SV */ svp = cSVOPx_svp(((BINOP*)o)->op_last); - if (!SvFAKE(sv = *svp) || !SvREADONLY(sv)) { + if ((!SvFAKE(sv = *svp) || !SvREADONLY(sv)) + && SvTYPE(sv) < SVt_PVMG && !SvROK(sv)) { key = SvPV_const(sv, keylen); lexname = newSVpvn_share(key, SvUTF8(sv) ? -(I32)keylen : (I32)keylen, -- cgit v1.2.1