Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: b1414dcb98d72036e17cb9d4c8aae9d7ad65113e
      
https://github.com/Perl/perl5/commit/b1414dcb98d72036e17cb9d4c8aae9d7ad65113e
  Author: Tony Cook <[email protected]>
  Date:   2023-02-08 (Wed, 08 Feb 2023)

  Changed paths:
    M op.c
    M sv.c
    M t/lib/warnings/op

  Log Message:
  -----------
  warn on redefining an array constant sub

The code in report_redefined_cv() would check whether the old
constant and the new constant were the same SV to avoid warning on
duplicate imports of the same constant.  Since both gv_setref()
and report_redefined_cv() used cv_const_sv() to fetch the constant
SV, which returns NULL for an AV based constant sub, the check
for the equivalent SV would compare NULL to NULL and
report_redefined_cv() would return early.

Additional checks were required further down to prevent sv_cmp()
being called on AVs.

The check for simple SV's allow redefinition of constant subs if the
new value string compares the same as the old value.  The AV check
does not try to allow that.

Fixed #20742


  Commit: dd3d299fefbbff9efe55eb16af5bb9aa0410d606
      
https://github.com/Perl/perl5/commit/dd3d299fefbbff9efe55eb16af5bb9aa0410d606
  Author: Tony Cook <[email protected]>
  Date:   2023-02-08 (Wed, 08 Feb 2023)

  Changed paths:
    M op.c
    M t/lib/warnings/op

  Log Message:
  -----------
  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


Compare: https://github.com/Perl/perl5/compare/6c19911f93fc...dd3d299fefbb

Reply via email to