Skip to content

Commit 6c69639

Browse files
committed
Partially revert fd88a92 - it's GvCVGEN(gv), not CvGEN(cv)
This commit partially reverts fd88a92 In two places in that commit, setting `GvCVGEN` to zero was changed to just asserting that the value was already zero, because the CV had just been created (with a Zeroed body). However, the value is set on a pre-existing GV, not on the fresh CV, so no assumptions should be made about the current value of `GvCVGEN`.
1 parent 3fbcd66 commit 6c69639

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

gv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ S_maybe_add_coresub(pTHX_ HV * const stash, GV *gv,
669669
get hairy. */
670670
cv = MUTABLE_CV(newSV_type(SVt_PVCV));
671671
GvCV_set(gv,cv);
672-
assert(GvCVGEN(gv) == 0);
672+
GvCVGEN(gv) = 0;
673673
CvISXSUB_on(cv);
674674
CvXSUB(cv) = core_xsub;
675675
PoisonPADLIST(cv);

op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12320,7 +12320,7 @@ Perl_newSTUB(pTHX_ GV *gv, bool fake)
1232012320
PERL_ARGS_ASSERT_NEWSTUB;
1232112321
assert(!GvCVu(gv));
1232212322
GvCV_set(gv, cv);
12323-
assert(GvCVGEN(gv) == 0);
12323+
GvCVGEN(gv) = 0;
1232412324
if (!fake && GvSTASH(gv) && HvENAME_HEK(GvSTASH(gv)))
1232512325
gv_method_changed(gv);
1232612326
if (SvFAKE(gv)) {

t/op/stash.t

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
set_up_inc( qw(../lib) );
77
}
88

9-
plan( tests => 55 );
9+
plan( tests => 56 );
1010

1111
# Used to segfault (bug #15479)
1212
fresh_perl_like(
@@ -356,3 +356,22 @@ is runperl(
356356
),
357357
"*main::main::\n",
358358
"[perl #129869] lookup %:: by name after clearing %::";
359+
360+
is runperl(
361+
prog => 'no strict q|refs|;
362+
Stash->can(q|Trash|);
363+
my $full_method = q|Stash::Trash|;
364+
# Save method
365+
my $mocked = \&{$full_method};
366+
# Replace method
367+
*{$full_method} = sub {};
368+
# Restore original method
369+
*{$full_method} = $mocked;
370+
# Stash::Trash should now be undefined
371+
my $coderef = sub { Stash::Trash() };
372+
$coderef->();
373+
',
374+
stderr => 1,
375+
),
376+
"Undefined subroutine &Stash::Trash called at -e line 11.\n",
377+
"[GH#23855], [GH#23856] Don't assume GvCVGEN(gv) value";

0 commit comments

Comments
 (0)