Commit f20abf98e9 for perl
commit f20abf98e95b8fd071347eaf86bf6e7e8d6a63f1
Author: Leon Timmermans <fawaka@gmail.com>
Date: Wed Oct 28 20:51:33 2026 +0100
Properly initialize ${^UTF8CACHE} in new threads
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 6048aba6bc..75dc8cb4a0 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -442,6 +442,10 @@ Z<>
This bug has now been fixed. [GH #24933]
+=item * Properly initialize ${^UTF8CACHE} in new threads
+
+Previously the UTF-8 cache wasn't enabled in new threads, leading to performance issues.
+
=back
=head1 Known Problems
diff --git a/sv.c b/sv.c
index 2a7106ccb1..5fc3cc13eb 100644
--- a/sv.c
+++ b/sv.c
@@ -17424,6 +17424,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_cv_has_eval = proto_perl->Icv_has_eval;
/* Unicode features (see perlrun/-C) */
PL_unicode = proto_perl->Iunicode;
+ PL_utf8cache = proto_perl->Iutf8cache;
/* Pre-5.8 signals control */
PL_signals = proto_perl->Isignals;
diff --git a/t/op/utf8cache.t b/t/op/utf8cache.t
index 68b6cc9023..714ef2f414 100644
--- a/t/op/utf8cache.t
+++ b/t/op/utf8cache.t
@@ -10,7 +10,7 @@ BEGIN {
use strict;
use Config ();
-plan(tests => 16);
+plan(tests => 17);
SKIP: {
skip_without_dynamic_extension("Devel::Peek", 2);
@@ -163,3 +163,10 @@ $ref = bless [], "αabcd_";
() = length $ref;
bless $ref, "α";
is length $ref, length "$ref", 'no utf8 length cache on references';
+
+SKIP: {
+ skip 'No threads', 1 unless $Config::Config{usethreads};
+ require threads;
+ my $val = threads->create(sub { ${^UTF8CACHE} })->join;
+ is $val, ${^UTF8CACHE}, '${^UTF8CACHE} has the correct value in child thread';
+}