Skip to content

Commit

Permalink
Remove unwarranted assertion in Perl_newATTRSUB_x()
Browse files Browse the repository at this point in the history
RT #126845: if a stub subroutine definition with a prototype has been seen,
then any subsequent stub (or definition) of the same subroutine with an
attribute was causing an assertion failure because of a null pointer.

This assertion was added in 2eaf799, which
itself would already have triggered this assertion failure, even though all
subsequent uses of the pointer in question were guarded with non-null
conditions. So merely deleting the assertion is the right thing.
  • Loading branch information
arc committed Jan 3, 2016
1 parent 83677dc commit a934a4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion op.c
Expand Up @@ -8407,7 +8407,6 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs,
const_sv = NULL;

if (SvPOK(gv) || (SvROK(gv) && SvTYPE(SvRV(gv)) != SVt_PVCV)) {
assert (block);
cv_ckproto_len_flags((const CV *)gv,
o ? (const GV *)cSVOPo->op_sv : NULL, ps,
ps_len, ps_utf8|CV_CKPROTO_CURSTASH);
Expand Down
9 changes: 8 additions & 1 deletion t/op/sub.t
Expand Up @@ -6,7 +6,7 @@ BEGIN {
set_up_inc('../lib');
}

plan(tests => 55);
plan(tests => 57);

sub empty_sub {}

Expand Down Expand Up @@ -246,6 +246,13 @@ predeclared(); # set $x to 42
$main::x = $main::x = "You should not see this.";
inside_predeclared(); # run test

# RT #126845: this used to fail an assertion in Perl_newATTRSUB_x()
eval 'sub rt126845_1 (); sub rt126845_1 () :lvalue';
pass("RT #126845: stub with prototype, then with attribute");

eval 'sub rt126845_2 (); sub rt126845_2 () :lvalue {}';
pass("RT #126845: stub with prototype, then definition with attribute");

# RT #124156 death during unwinding causes crash
# the tie allows us to trigger another die while cleaning up the stack
# from an earlier die.
Expand Down

0 comments on commit a934a4a

Please sign in to comment.