From dd3d299fefbbff9efe55eb16af5bb9aa0410d606 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Wed, 1 Feb 2023 14:50:22 +1100 Subject: newATTRSUB_x: don't try to sv_cmp() an AV* newATTRSUB_x() does it's own constant sub redefinition checks, but if you tried to redefine a constant.pm defined constant list sub with an old style constant sub C<< sub foo() { CONSTANT } >> it would cause an assertion failure trying to SvPV() an SV inside sv_cmp(): $ ~/perl/v5.36.0-dbg-san/bin/perl -Mconstant=x,1,2 -e 'sub x() { 1 }' perl: sv.c:2820: char *Perl_sv_2pv_flags(SV *const, STRLEN *const, const U32): Assertion `SvTYPE(sv) != SVt_PVAV && SvTYPE(sv) != SVt_PVHV && SvTYPE(sv) != SVt_PVFM' failed. Aborted --- op.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'op.c') diff --git a/op.c b/op.c index 2be77d063f..d807c6f8b2 100644 --- a/op.c +++ b/op.c @@ -10661,7 +10661,9 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, if (ckWARN(WARN_REDEFINE) || ( ckWARN_d(WARN_REDEFINE) && ( !const_sv || SvRV(gv) == const_sv - || sv_cmp(SvRV(gv), const_sv) ))) { + || SvTYPE(const_sv) == SVt_PVAV + || SvTYPE(SvRV(gv)) == SVt_PVAV + || sv_cmp(SvRV(gv), const_sv) ))) { assert(cSVOPo); Perl_warner(aTHX_ packWARN(WARN_REDEFINE), "Constant subroutine %" SVf " redefined", -- cgit v1.2.1