summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-06-04 19:14:33 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-06-04 19:29:04 -0700
commit4ab5bd5f1ac4d396ccef2207abef0c1e6fe14b66 (patch)
tree611d1041c686edb69557bfdfd73d7c1ca43fd077
parent47d6f3d6640ee5a8c3c6670383171a78d34abbaa (diff)
downloadperl-4ab5bd5f1ac4d396ccef2207abef0c1e6fe14b66.tar.gz
Make Devel::Peek::fill_mstats work on COWs
-rw-r--r--ext/Devel-Peek/Peek.xs1
-rw-r--r--ext/Devel-Peek/t/Peek.t8
2 files changed, 9 insertions, 0 deletions
diff --git a/ext/Devel-Peek/Peek.xs b/ext/Devel-Peek/Peek.xs
index 3dcba4780e..5e8deb9830 100644
--- a/ext/Devel-Peek/Peek.xs
+++ b/ext/Devel-Peek/Peek.xs
@@ -161,6 +161,7 @@ fill_mstats(SV *sv, int level)
{
dTHX;
+ if (SvIsCOW(sv)) sv_force_normal(sv);
if (SvREADONLY(sv))
croak("Cannot modify a readonly value");
SvGROW(sv, sizeof(struct mstats_buffer)+1);
diff --git a/ext/Devel-Peek/t/Peek.t b/ext/Devel-Peek/t/Peek.t
index 5c6b315265..8eedf530b1 100644
--- a/ext/Devel-Peek/t/Peek.t
+++ b/ext/Devel-Peek/t/Peek.t
@@ -770,4 +770,12 @@ do_test('ENAMEs on a stash with no NAME',
ENAME = "RWOM", "KLANK" # $] > 5.012
');
+SKIP: {
+ skip "Not built with usemymalloc", 1
+ unless $Config{usemymalloc} eq 'y';
+ my $x = __PACKAGE__;
+ ok eval { fill_mstats($x); 1 }, 'fill_mstats on COW scalar'
+ or diag $@;
+}
+
done_testing();