Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S_fold_constants: remove early SvREADONLY(sv) to allow SvIsCOW(sv) #20595

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/Devel-Peek/t/Peek.t
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ do_test('string with Unicode',
. '"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
CUR = 5
LEN = \\d+
COW_REFCNT = 1 # $] < 5.019007
COW_REFCNT = 1 # $] < 5.019007 || $] >=5.041000
');

do_test('reference to hash containing Unicode',
Expand All @@ -558,7 +558,7 @@ do_test('reference to hash containing Unicode',
PV = $ADDR "' . $cp200_bytes . '"\\\0 \[UTF8 "\\\x\{200\}"\]
CUR = 2
LEN = \\d+
COW_REFCNT = 1 # $] < 5.019007
COW_REFCNT = 1 # $] < 5.019007 || $] >=5.041000
', '',
$] >= 5.015
? undef
Expand Down
4 changes: 3 additions & 1 deletion op.c
Original file line number Diff line number Diff line change
Expand Up @@ -5081,7 +5081,9 @@ S_fold_constants(pTHX_ OP *const o)
SvPADTMP_off(sv);
else if (!SvIMMORTAL(sv)) {
SvPADTMP_on(sv);
SvREADONLY_on(sv);
/* Do not set SvREADONLY(sv) here. newSVOP will call
* Perl_ck_svconst, which will do it. Setting it early
* here prevents Perl_ck_svconst from setting SvIsCOW(sv).*/
}
newop = newSVOP(OP_CONST, 0, MUTABLE_SV(sv));
if (!is_stringify) newop->op_folded = 1;
Expand Down
4 changes: 3 additions & 1 deletion t/op/undef.t
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ SKIP: {
my $out = runperl(stderr => 1,
progs => [ split /\n/, <<'EOS' ]);
require Devel::Peek;
my $f = q(x) x 40; $f = undef;
my $f = q(x) x 40;
chop $f; # Make sure that the PV buffer is not COWed
$f = undef;
Devel::Peek::Dump($f);
undef $f;
Devel::Peek::Dump($f);
Expand Down
Loading