summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c1
-rw-r--r--t/op/tr.t18
2 files changed, 18 insertions, 1 deletions
diff --git a/op.c b/op.c
index 54d2a64a78..d7ef32c3cd 100644
--- a/op.c
+++ b/op.c
@@ -3345,6 +3345,7 @@ S_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
SvREFCNT_dec(PAD_SVl(cPADOPo->op_padix));
PAD_SETSV(cPADOPo->op_padix, swash);
SvPADTMP_on(swash);
+ SvREADONLY_on(swash);
#else
cSVOPo->op_sv = swash;
#endif
diff --git a/t/op/tr.t b/t/op/tr.t
index 9273e09d19..3f85e43758 100644
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 118;
+plan tests => 119;
my $Is_EBCDIC = (ord('i') == 0x89 & ord('J') == 0xd1);
@@ -468,3 +468,19 @@ my $wasro = Internals::SvREADONLY($s);
$s =~ tr/i//;
ok( Internals::SvREADONLY($s), "count-only tr doesn't deCOW COWs" );
}
+
+# [ RT #61520 ]
+#
+# under threads, unicode tr within a cloned closure would SEGV or assert
+# fail, since the pointer in the pad to the swash was getting zeroed out
+# in the proto-CV
+
+{
+ my $x = "\x{142}";
+ sub {
+ $x =~ tr[\x{142}][\x{143}];
+ }->();
+ is($x,"\x{143}", "utf8 + closure");
+}
+
+