summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--t/run/switchd.t24
-rw-r--r--util.c1
2 files changed, 24 insertions, 1 deletions
diff --git a/t/run/switchd.t b/t/run/switchd.t
index f901bf620e..b5d4d42f9a 100644
--- a/t/run/switchd.t
+++ b/t/run/switchd.t
@@ -9,7 +9,7 @@ BEGIN { require "./test.pl"; }
# This test depends on t/lib/Devel/switchd*.pm.
-plan(tests => 17);
+plan(tests => 18);
my $r;
@@ -253,3 +253,25 @@ is(
"ok\n",
"setting breakpoints without *DB::dbline aliased"
);
+
+# [perl #121255]
+# Check that utf8 caches are flushed when $DB::sub is set
+is(
+ runperl(
+ switches => [ '-Ilib', '-d:switchd_empty' ],
+ progs => [ split "\n",
+ 'sub DB::sub{length($DB::sub); goto &$DB::sub}
+ ${^UTF8CACHE}=-1;
+ print
+ eval qq|sub oo\x{25f} { 42 }
+ sub ooooo\x{25f} { oo\x{25f}() }
+ ooooo\x{25f}()|
+ || $@,
+ qq|\n|;
+ '
+ ],
+ stderr => 1
+ ),
+ "42\n",
+ 'UTF8 length caches on $DB::sub are flushed'
+);
diff --git a/util.c b/util.c
index 6dc39f0a49..5541ac9e14 100644
--- a/util.c
+++ b/util.c
@@ -5334,6 +5334,7 @@ Perl_get_db_sub(pTHX_ SV **svp, CV *cv)
(void)SvIOK_on(dbsv);
SvIV_set(dbsv, PTR2IV(cv)); /* Do it the quickest way */
}
+ SvSETMAGIC(dbsv);
TAINT_IF(save_taint);
#ifdef NO_TAINT_SUPPORT
PERL_UNUSED_VAR(save_taint);