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

BBC: Blead Breaks Variable::Magic, Devel::Caller #20114

Closed
cjg-cguevara opened this issue Aug 18, 2022 · 44 comments · Fixed by richardc/perl-devel-caller#2
Closed

BBC: Blead Breaks Variable::Magic, Devel::Caller #20114

cjg-cguevara opened this issue Aug 18, 2022 · 44 comments · Fixed by richardc/perl-devel-caller#2
Assignees
Labels
BBC Blead Breaks CPAN - changes in blead broke a cpan module(s) Not a Release Blocker

Comments

@cjg-cguevara
Copy link

This is a bug report for perl from "Carlos Guevara" carlos@carlosguevara.com,
generated with the help of perlbug 1.42 running under perl 5.37.3.


[Please describe your issue here]

BBC: Blead Breaks Variable::Magic

Please see http://matrix.cpantesters.org/?dist=Variable::Magic

[Please do not change anything below this line]


Flags:
category=core
severity=low

Site configuration information for perl 5.37.3:

Configured by cpan at Thu Aug 18 01:16:20 EDT 2022.

Summary of my perl5 (revision 5 version 37 subversion 3) configuration:
Commit id: bbae2b2
Platform:
osname=openbsd
osvers=7.1
archname=OpenBSD.amd64-openbsd
uname='openbsd cjg-openbsd7 7.1 generic#3 amd64 '
config_args='-des -Dprefix=/bin/perl-blead -Dscriptdir=/bin/perl-blead/bin -Dusedevel -Duse64bitall'
hint=recommended
useposix=true
d_sigaction=define
useithreads=undef
usemultiplicity=undef
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
optimize='-O2'
cppflags='-fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='OpenBSD Clang 13.0.0'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='cc'
ldflags ='-Wl,-E -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/lib/clang/13.0.0/lib /usr/lib /usr/local/lib
libs=-lpthread -lm -lutil -lc
perllibs=-lpthread -lm -lutil -lc
libc=/usr/lib/libc.so.96.1
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags=' '
cccdlflags='-DPIC -fPIC '
lddlflags='-shared -fPIC -L/usr/local/lib -fstack-protector-strong'


@inc for perl 5.37.3:
/home/cpan/bin/perl-blead/lib/site_perl/5.37.3/OpenBSD.amd64-openbsd
/home/cpan/bin/perl-blead/lib/site_perl/5.37.3
/home/cpan/bin/perl-blead/lib/5.37.3/OpenBSD.amd64-openbsd
/home/cpan/bin/perl-blead/lib/5.37.3


Environment for perl 5.37.3:
HOME=/home/cpan
LANG (unset)
LANGUAGE (unset)
LC_ALL=C
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/cpan/bin/perl-blead/bin:/home/cpan/bin:/home/cpan/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games
PERL_BADLANG (unset)
SHELL=/usr/local/bin/bash

@bram-perl
Copy link

bram-perl commented Aug 18, 2022

Looing at a cpan test report1:

#   Failed test 'get magic with op_info == 1 gets the right op info'
#   at t/18-opinfo.t line 79.
#          got: 'padsv_store'
#     expected: 'sassign'

so I'm guessing this was "caused" by commit 9fdd7fc : ( @richardleach )

Author:     Richard Leach <rich+perl@hyphen-dash-hyphen.info>
AuthorDate: Fri Jul 8 14:52:19 2022 +0000
Commit:     Richard Leach <rich+perl@hyphen-dash-hyphen.info>
CommitDate: Wed Aug 17 11:19:10 2022 +0100

    Implement OP_PADSV_STORE - combined sassign/padsv OP

    This commit introduces a new OP to replace simple cases
    of OP_SASSIGN and OP_PADSV.

    For example, 'my $x = 1' is currently implemented as:

    1  <;> nextstate(main 1 -e:1) v:{
    2  <$> const(IV 1) s
    3  <0> padsv[$x:1,2] sRM*/LVINTRO
    4  <2> sassign vKS/2

    But now will be turned into:

    1  <;> nextstate(main 1 -e:1) v:{
    2  <$> const(IV 1) s
    3  <1> padsv_store[$x:1,2] vKMS/LVINTRO

    This intended to be a transparent performance optimization.
    It should be applicable for RHS optrees of varying complexity.

(so the change is probably expected and Variable::Magic needs fixing)

Footnotes

  1. https://www.cpantesters.org/cpan/report/75319c30-1e93-11ed-9158-438a229a9fdc

@jkeenan
Copy link
Contributor

jkeenan commented Aug 18, 2022

Bisection points to this commit:

9fdd7fc4796d89d16dceea42f2af91e4fde296ed is the first bad commit
commit 9fdd7fc4796d89d16dceea42f2af91e4fde296ed
Author: Richard Leach <richardleach@users.noreply.github.com>
Date:   Fri Jul 8 14:52:19 2022 +0000
Commit:     Richard Leach <rich+perl@hyphen-dash-hyphen.info>
CommitDate: Wed Aug 17 11:19:10 2022 +0100


    Implement OP_PADSV_STORE - combined sassign/padsv OP

@richardleach, can you take a look?

@jkeenan jkeenan added BBC Blead Breaks CPAN - changes in blead broke a cpan module(s) and removed Needs Triage labels Aug 18, 2022
@andk
Copy link
Contributor

andk commented Aug 19, 2022

Also affected: RCLAMP/Devel-Caller-2.06.tar.gz
Fail report: http://www.cpantesters.org/cpan/report/c1521d8a-1f31-11ed-90cd-b2ccdf0dbbbc

@richardleach richardleach self-assigned this Aug 19, 2022
@richardleach
Copy link
Contributor

Also affected: RCLAMP/Devel-Caller-2.06.tar.gz Fail report: http://www.cpantesters.org/cpan/report/c1521d8a-1f31-11ed-90cd-b2ccdf0dbbbc

Patch for Devel::Caller supplied in https://rt.cpan.org/Ticket/Display.html?id=144051

@richardleach
Copy link
Contributor

BBC: Blead Breaks Variable::Magic

Patch for Variable::Magic supplied in https://rt.cpan.org/Ticket/Display.html?id=144052

@jkeenan jkeenan changed the title BBC: Blead Breaks Variable::Magic BBC: Blead Breaks Variable::Magic, Devel::Caller Aug 19, 2022
@jkeenan
Copy link
Contributor

jkeenan commented Aug 19, 2022

In addition to the test failures previously reported in Variable::Magic, we're also getting failures in 2 test files which are only run on threaded builds (which implies that the patch already sent upstream for this module will not be sufficient).

CPAN distribution Variable-Magic is experiencing test failures against Perl 5 blead. CPANtesters results here. Failures occur against both unthreaded and threaded builds.

Sample failures in a threaded build on FreeBSD-12:

[perlmonger: Variable-Magic-0.62] $ bleadperl -v | head -2 | tail -1
This is perl 5, version 37, subversion 3 (v5.37.3 (v5.37.2-211-gc3d21af2da)) built for amd64-freebsd-thread-multi
[perlmonger: Variable-Magic-0.62] $ bleadperl -V:config_args
config_args='-des -Dusedevel -Uversiononly -Dprefix=/home/jkeenan/testing/blead -Dman1dir=none -Dman3dir=none -Duseithreads -Doptimize=-O2 -pipe -fstack-protector -fno-strict-aliasing';
[perlmonger: Variable-Magic-0.62] $ bleadprove -V
TAP::Harness v3.44 and Perl v5.37.3
[perlmonger: Variable-Magic-0.62] $ bleadprove -vb t/40-threads.t t/41-clone.t 
t/40-threads.t .. # Using threads 2.29
# Using threads::shared 1.65

ok 1 - wizard in thread 1 doesn't croak
ok 2 - wizard in thread 1 is defined
ok 3 - wizard in thread 1 doesn't trigger magic
ok 4 - cast in thread 1 doesn't croak
ok 5 - cast in thread 1 doesn't trigger magic
ok 6 - get in thread 1 doesn't croak
ok 7 - get in thread 1 returns the right thing
ok 8 - get in thread 1 triggers magic
ok 9 - getdata in thread 1 doesn't croak
ok 10 - getdata in thread 1 returns the right thing
ok 11 - getdata in thread 1 doesn't trigger magic
not ok 12 - op name in thread 1 is correct
ok 13 - set in thread 1 (check opname) doesn't croak
ok 14 - dispell in thread 1 doesn't croak
ok 15 - dispell in thread 1 doesn't trigger magic
ok 16 - get in thread 1 after dispell doesn't croak
ok 17 - get in thread 1 after dispell returns the right thing
ok 18 - get in thread 1 after dispell doesn't trigger magic
ok 19 - wizard in thread 2 doesn't croak
ok 20 - wizard in thread 2 is defined
ok 21 - wizard in thread 2 doesn't trigger magic
ok 22 - cast in thread 2 doesn't croak
ok 23 - cast in thread 2 doesn't trigger magic
ok 24 - get in thread 2 doesn't croak
ok 25 - get in thread 2 returns the right thing
ok 26 - get in thread 2 triggers magic
ok 27 - getdata in thread 2 doesn't croak
ok 28 - getdata in thread 2 returns the right thing
ok 29 - getdata in thread 2 doesn't trigger magic
not ok 30 - op name in thread 2 is correct
ok 31 - set in thread 2 (check opname) doesn't croak
ok 32 - dispell in thread 2 doesn't croak
ok 33 - dispell in thread 2 doesn't trigger magic
ok 34 - get in thread 2 after dispell doesn't croak
ok 35 - get in thread 2 after dispell returns the right thing
ok 36 - get in thread 2 after dispell doesn't trigger magic
ok 37 - wizard in thread 3 doesn't croak
ok 38 - wizard in thread 3 is defined
ok 39 - wizard in thread 3 doesn't trigger magic
ok 40 - cast in thread 3 doesn't croak
ok 41 - cast in thread 3 doesn't trigger magic
ok 42 - get in thread 3 doesn't croak
ok 43 - get in thread 3 returns the right thing
ok 44 - get in thread 3 triggers magic
ok 45 - getdata in thread 3 doesn't croak
ok 46 - getdata in thread 3 returns the right thing
ok 47 - getdata in thread 3 doesn't trigger magic
not ok 48 - op object in thread 3 is correct
ok 49 - set in thread 3 (check opname) doesn't croak
ok 50 - dispell in thread 3 doesn't croak
ok 51 - dispell in thread 3 doesn't trigger magic
ok 52 - get in thread 3 after dispell doesn't croak
ok 53 - get in thread 3 after dispell returns the right thing
ok 54 - get in thread 3 after dispell doesn't trigger magic
ok 55 - wizard in thread 4 doesn't croak
ok 56 - wizard in thread 4 is defined
ok 57 - wizard in thread 4 doesn't trigger magic
ok 58 - cast in thread 4 doesn't croak
ok 59 - cast in thread 4 doesn't trigger magic
ok 60 - get in thread 4 doesn't croak
ok 61 - get in thread 4 returns the right thing
ok 62 - get in thread 4 triggers magic
ok 63 - getdata in thread 4 doesn't croak
ok 64 - getdata in thread 4 returns the right thing
ok 65 - getdata in thread 4 doesn't trigger magic
not ok 66 - op object in thread 4 is correct
ok 67 - set in thread 4 (check opname) doesn't croak
ok 68 - dispell in thread 4 doesn't croak
ok 69 - dispell in thread 4 doesn't trigger magic
ok 70 - get in thread 4 after dispell doesn't croak
ok 71 - get in thread 4 after dispell returns the right thing
ok 72 - get in thread 4 after dispell doesn't trigger magic
ok 73 - destructors
ok 74 - wizard in thread 5 doesn't croak
ok 75 - wizard in thread 5 is defined
ok 76 - wizard in thread 5 doesn't trigger magic
ok 77 - cast in thread 5 doesn't croak
ok 78 - cast in thread 5 doesn't trigger magic
ok 79 - get in thread 5 doesn't croak
ok 80 - get in thread 5 returns the right thing
ok 81 - get in thread 5 triggers magic
ok 82 - getdata in thread 5 doesn't croak
ok 83 - getdata in thread 5 returns the right thing
ok 84 - getdata in thread 5 doesn't trigger magic
not ok 85 - op name in thread 5 is correct
ok 86 - set in thread 5 (check opname) doesn't croak
ok 87 - wizard in thread 6 doesn't croak
ok 88 - wizard in thread 6 is defined
ok 89 - wizard in thread 6 doesn't trigger magic
ok 90 - cast in thread 6 doesn't croak
ok 91 - cast in thread 6 doesn't trigger magic
ok 92 - get in thread 6 doesn't croak
ok 93 - get in thread 6 returns the right thing
ok 94 - get in thread 6 triggers magic
ok 95 - getdata in thread 6 doesn't croak
ok 96 - getdata in thread 6 returns the right thing
ok 97 - getdata in thread 6 doesn't trigger magic
not ok 98 - op name in thread 6 is correct
ok 99 - set in thread 6 (check opname) doesn't croak
ok 100 - wizard in thread 7 doesn't croak
ok 101 - wizard in thread 7 is defined
ok 102 - wizard in thread 7 doesn't trigger magic
ok 103 - cast in thread 7 doesn't croak
ok 104 - cast in thread 7 doesn't trigger magic
ok 105 - get in thread 7 doesn't croak
ok 106 - get in thread 7 returns the right thing
ok 107 - get in thread 7 triggers magic
ok 108 - getdata in thread 7 doesn't croak
ok 109 - getdata in thread 7 returns the right thing
ok 110 - getdata in thread 7 doesn't trigger magic
not ok 111 - op object in thread 7 is correct
ok 112 - set in thread 7 (check opname) doesn't croak
ok 113 - wizard in thread 8 doesn't croak
ok 114 - wizard in thread 8 is defined
ok 115 - wizard in thread 8 doesn't trigger magic
ok 116 - cast in thread 8 doesn't croak
ok 117 - cast in thread 8 doesn't trigger magic
ok 118 - get in thread 8 doesn't croak
ok 119 - get in thread 8 returns the right thing
ok 120 - get in thread 8 triggers magic
ok 121 - getdata in thread 8 doesn't croak
ok 122 - getdata in thread 8 returns the right thing
ok 123 - getdata in thread 8 doesn't trigger magic
not ok 124 - op object in thread 8 is correct
ok 125 - set in thread 8 (check opname) doesn't croak
ok 126 - destructors
1..126
Dubious, test returned 8 (wstat 2048, 0x800)
Failed 8/126 subtests 
t/41-clone.t .... # Using threads 2.29
# Using threads::shared 1.65

ok 1 - wizard with op_info 1 in main thread doesn't croak
ok 2 - wizard with op_info 1 in main thread is defined
ok 3 - wizard with op_info 1 in main thread doesn't trigger magic
ok 4 - wizard with op_info 2 in main thread doesn't croak
ok 5 - wizard with op_info 2 in main thread is defined
ok 6 - wizard with op_info 2 in main thread doesn't trigger magic
ok 7 - cast in thread 1 doesn't croak
ok 8 - get in thread 1 doesn't croak
ok 9 - get in thread 1 returns the right thing
ok 10 - getdata in thread 1 doesn't croak
ok 11 - getdata in thread 1 returns the right thing
not ok 12 - op name in thread 1 is correct
ok 13 - set in thread 1 (check opname) doesn't croak
ok 14 - dispell in thread 1 doesn't croak
ok 15 - get in thread 1 after dispell doesn't croak
ok 16 - get in thread 1 after dispell returns the right thing
ok 17 - cast in thread 2 doesn't croak
ok 18 - get in thread 2 doesn't croak
ok 19 - get in thread 2 returns the right thing
ok 20 - getdata in thread 2 doesn't croak
ok 21 - getdata in thread 2 returns the right thing
not ok 22 - op name in thread 2 is correct
ok 23 - set in thread 2 (check opname) doesn't croak
ok 24 - dispell in thread 2 doesn't croak
ok 25 - get in thread 2 after dispell doesn't croak
ok 26 - get in thread 2 after dispell returns the right thing
ok 27 - get triggered twice
ok 28 - destructors
ok 29 - cast in thread 3 doesn't croak
ok 30 - get in thread 3 doesn't croak
ok 31 - get in thread 3 returns the right thing
ok 32 - getdata in thread 3 doesn't croak
ok 33 - getdata in thread 3 returns the right thing
not ok 34 - op object in thread 3 is correct
ok 35 - set in thread 3 (check opname) doesn't croak
ok 36 - dispell in thread 3 doesn't croak
ok 37 - get in thread 3 after dispell doesn't croak
ok 38 - get in thread 3 after dispell returns the right thing
ok 39 - cast in thread 4 doesn't croak
ok 40 - get in thread 4 doesn't croak
ok 41 - get in thread 4 returns the right thing
ok 42 - getdata in thread 4 doesn't croak
ok 43 - getdata in thread 4 returns the right thing
not ok 44 - op object in thread 4 is correct
ok 45 - set in thread 4 (check opname) doesn't croak
ok 46 - dispell in thread 4 doesn't croak
ok 47 - get in thread 4 after dispell doesn't croak
ok 48 - get in thread 4 after dispell returns the right thing
ok 49 - get triggered twice
ok 50 - destructors
ok 51 - cast in thread 5 doesn't croak
ok 52 - get in thread 5 doesn't croak
ok 53 - get in thread 5 returns the right thing
ok 54 - getdata in thread 5 doesn't croak
ok 55 - getdata in thread 5 returns the right thing
not ok 56 - op name in thread 5 is correct
ok 57 - set in thread 5 (check opname) doesn't croak
ok 58 - cast in thread 6 doesn't croak
ok 59 - get in thread 6 doesn't croak
ok 60 - get in thread 6 returns the right thing
ok 61 - getdata in thread 6 doesn't croak
ok 62 - getdata in thread 6 returns the right thing
not ok 63 - op name in thread 6 is correct
ok 64 - set in thread 6 (check opname) doesn't croak
ok 65 - get triggered twice
ok 66 - destructors
ok 67 - cast in thread 7 doesn't croak
ok 68 - get in thread 7 doesn't croak
ok 69 - get in thread 7 returns the right thing
ok 70 - getdata in thread 7 doesn't croak
ok 71 - getdata in thread 7 returns the right thing
not ok 72 - op object in thread 7 is correct
ok 73 - set in thread 7 (check opname) doesn't croak
ok 74 - cast in thread 8 doesn't croak
ok 75 - get in thread 8 doesn't croak
ok 76 - get in thread 8 returns the right thing
ok 77 - getdata in thread 8 doesn't croak
ok 78 - getdata in thread 8 returns the right thing
not ok 79 - op object in thread 8 is correct
ok 80 - set in thread 8 (check opname) doesn't croak
ok 81 - get triggered twice
ok 82 - destructors
ok 83 - wizard is destroyed
ok 84 - set callback called in thread 13
ok 85 - set callback called in thread 11
ok 86 - set callback called in thread 10
ok 87 - set callback called in thread 9
ok 88 - $var could be assigned to in thread 10
ok 89 - $var could be assigned to in thread 9
ok 90 - $var could be assigned to in thread 11
ok 91 - $var could be assigned to in thread 13
ok 92 - set callback called in thread 12
ok 93 - $var could be assigned to in thread 12
1..93
Dubious, test returned 8 (wstat 2048, 0x800)
Failed 8/93 subtests 

Test Summary Report
-------------------
t/40-threads.t (Wstat: 2048 (exited 8) Tests: 126 Failed: 8)
  Failed tests:  12, 30, 48, 66, 85, 98, 111, 124
  Non-zero exit status: 8
t/41-clone.t  (Wstat: 2048 (exited 8) Tests: 93 Failed: 8)
  Failed tests:  12, 22, 34, 44, 56, 63, 72, 79
  Non-zero exit status: 8
Files=2, Tests=219,  1 wallclock secs ( 0.05 usr  0.01 sys +  0.59 cusr  0.07 csys =  0.72 CPU)
Result: FAIL

Bisecting points to the same commit previously identified: 9fdd7fc

@richardleach
Copy link
Contributor

Thanks for the details. I've updated https://rt.cpan.org/Ticket/Display.html?id=144052 with a revised patch for Variable::Magic.

@andk
Copy link
Contributor

andk commented Aug 22, 2022

Also affected:
(1) TEAM/Mixin-Event-Dispatch-2.000.tar.gz http://www.cpantesters.org/cpan/report/73d12f5e-20f0-11ed-9c06-d447210175d9
(2) KRYDE/Test-Weaken-3.022000.tar.gz http://www.cpantesters.org/cpan/report/673fa6ee-216d-11ed-a68c-e7fefc3f6622

@richardleach
Copy link
Contributor

Thanks, I'll take a look this evening.

@demerphq
Copy link
Collaborator

IMO we should define an "opcode version" magic var, define, whatever, that people can test.

If they look at our optree they should check the opcode-version, if they are not up to date they should not claim their tests are broken, they should report they have not updated the module to handle that latest version. Calling these types of issue an "error" is really unhelpful. We have to be able to make changes to the optree that perl executes. Heck you could argue we have the right to /entirely eliminate any idea of an optree at all/ as it is all just an implementation detail of the language internals itself. As such there is a big distinction between "this is broken because we changed how old things worked" and "this broken because we no longer do things that way". From the module point of view its much of a muchness, the module just doesn't work, but there is a big difference between an unadvertised (or even unanticipated) change of behavior in an existing opcode, and an advertised deliberate change to use a totally new opcode. Eg, "I havent update this module to work with this perl" is quite different from "you broke this module".

Until we have an opcode version we simply have nothing to test against, and a cpan module author has no other choice but to "just fail the tests", which then make core dev look bad when in fact its just a natural part of improving the language.

@richardleach
Copy link
Contributor

The Mixin::Event::Dispatch and Test::Weaken breakage was down to a bug, which has been fixed in 6f62971

Variable::Magic and Devel::Caller failures weren't caused by this bug, they still need the submitted patches (or similar) applying.

@andk
Copy link
Contributor

andk commented Aug 29, 2022

Also affected: ZEFRAM/Memoize-Once-0.002.tar.gz
Fail report: http://www.cpantesters.org/cpan/report/7bcb7860-2742-11ed-986e-58f48ac53a74
Stack trace:

Core was generated by `/home/sand/src/perl/repoperls/installed-perls/host/k93msid/v5.37.2-224-g29b290c'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  Perl_rpeep (my_perl=0x55cfc01a62a0, o=0x55cfc01f2a68) at peep.c:3880
3880    peep.c: No such file or directory.
(gdb) bt
#0  Perl_rpeep (my_perl=0x55cfc01a62a0, o=0x55cfc01f2a68) at peep.c:3880
#1  0x000055cfbe7b4983 in Perl_rpeep (my_perl=0x55cfc01a62a0, o=<optimized out>) at peep.c:2712
#2  0x000055cfbe5d2430 in S_process_optree (my_perl=0x55cfc01a62a0, cv=0x55cfc01da558, optree=0x55cfc0a4a330, start=<optimized out>) at op.c:2740
#3  0x000055cfbe5eff53 in Perl_newATTRSUB_x (my_perl=my_perl@entry=0x55cfc01a62a0, floor=<optimized out>, o=<optimized out>, proto=<optimized out>, attrs=<optimized out>, block=0x55cfc0a4a330, 
    o_is_gv=<optimized out>) at op.c:10613
#4  0x000055cfbe65b258 in Perl_yyparse (my_perl=my_perl@entry=0x55cfc01a62a0, gramtype=gramtype@entry=258) at /tmp/loop_over_clonedir-3655927-iBpvU_/perly.y:355
#5  0x000055cfbe605e12 in S_parse_body (xsinit=0x55cfbe5cf5b0 <xs_init>, env=0x0, my_perl=0x55cfc01a62a0) at perl.c:2595
#6  perl_parse (my_perl=0x55cfc01a62a0, xsinit=xsinit@entry=0x55cfbe5cf5b0 <xs_init>, argc=<optimized out>, argv=<optimized out>, env=env@entry=0x0) at perl.c:1903
#7  0x000055cfbe5cf3ec in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at perlmain.c:106

@richardleach , can you have a look, please?

@andk
Copy link
Contributor

andk commented Sep 2, 2022

Ping. Or would it be preferred that I write a new ticket for Memoize::Once and whatever comes next?

@richardleach
Copy link
Contributor

Adding to this ticket is fine if you like. I had a quick squint at Memoize::Once, but am waiting until this weekend to properly dig into it.

@andk
Copy link
Contributor

andk commented Sep 3, 2022

Also affected: OALDERS/App-perlvars-0.000004.tar.gz
Fail report: http://www.cpantesters.org/cpan/report/b070d2ce-2a3d-11ed-a5c0-ee11e8a79f68
Probably only an indirect breakage of a dependency? Hi Olaf @oalders , please take note.

@oalders
Copy link
Contributor

oalders commented Sep 3, 2022

Probably only an indirect breakage of a dependency? Hi Olaf @oalders , please take note.

Thanks @andk. I'm guessing an issue with Test::Vars. I can have a closer look next week.

@richardleach
Copy link
Contributor

Probably only an indirect breakage of a dependency? Hi Olaf @oalders , please take note.

Thanks @andk. I'm guessing an issue with Test::Vars. I can have a closer look next week.

I'm looking at Memoize::Once this weekend, so won't have time to properly look at this one yet. I had a quick squint at Test::Vars, and it might (hopefully) be as simple as adding padsv_store into the list of ops at https://metacpan.org/release/GFUJI/Test-Vars-0.015/source/lib/Test/Vars.pm#L264

    foreach my $op(qw(padsv padav padhv padcv match multideref subst)){

@richardleach
Copy link
Contributor

Also affected: ZEFRAM/Memoize-Once-0.002.tar.gz Fail report: http://www.cpantesters.org/cpan/report/7bcb7860-2742-11ed-986e-58f48ac53a74 Stack trace:

I think I understand what Memoize::Once is doing - essentially wiring in an SASSIGN and an ORASSIGN that point to non-standard pp_ functions. I need to experiment more, but the solution might be to essentially do the PADSV_STORE optimization inside *THK_ck_entersub_once.

Note: I have a busy work-week ahead and minor surgery on Friday, so might not get back to this until next weekend/the week after.

@richardleach
Copy link
Contributor

Alternatively, since pp_sassign doesn't use the OPf_SPECIAL flag, Memoize::Once could be modified to set that on the SASSIGN that it creates, and the peephole code for PADSV_STORE be modified to not optimize any SASSIGN with that flag set.

The previous idea is cleaner and doesn't mean that core would have to be modified just to make this module work. On the other hand, the OPf_SPECIAL flag approach requires minimal changes to Memoize::Once and wouldn't require the module to be updated again when additional optimizations (e.g. #20063) or optree changes come along.

@richardleach
Copy link
Contributor

Late-night realization: that's probably all complete nonsense, and the "problem" is that the peephole optimization for PADSV_STORE doesn't expect the op to be reached via op_other, as I've not seen that anywhere other than in the optree output by Memoize::Once. Amending the peephole optimization should be straightforward.

@richardleach
Copy link
Contributor

Merged a very minor and straightforward tweak to PADSV_STORE's peephole optimization to skip the kind of SASSIGN ops emitted by Memoize::Once: c5bbf81

@richardleach
Copy link
Contributor

Summarizing the still-broken packages from this issue:

  • Variable::Magic and Devel::Caller - they need updating to take account of the new OP. Patches supplied, but no releases incorporating them as-yet AFAIK.
  • OALDERS/App-perlvars-0.000004.tar.gz - broken, most probably due to Test::Vars. This is next on my list to look at; initially looks like Test::Vars will need updating to account for the new OP, rather than a bug fix or workaround needed in perl itself.

@jkeenan
Copy link
Contributor

jkeenan commented Sep 6, 2022

Summarizing the still-broken packages from this issue:
[snip]
* OALDERS/App-perlvars-0.000004.tar.gz - broken, most probably due to Test::Vars. This is next on my list to look at; initially looks like Test::Vars will need updating to account for the new OP, rather than a bug fix or workaround needed in perl itself.

The CPANtesters reports for Test-Vars are not consistently showing failures; only 4 runs on Linux are doing so. Just now, I was able to install Test::Vars against Perl 5 blead at 8975221 on FreeBSD-12 -- but when I then tried to install App::perlvars against that same perl, I got failures similar to those being reported at http://matrix.cpantesters.org/?dist=App-perlvars+0.000004.

Hence, patching Test::Vars might not be part of the resolution of this ticket.

@jkeenan
Copy link
Contributor

jkeenan commented Sep 7, 2022

Summarizing the still-broken packages from this issue:
[snip]

  • OALDERS/App-perlvars-0.000004.tar.gz - broken, most probably due to Test::Vars. This is next on my list to look at; initially looks like Test::Vars will need updating to account for the new OP, rather than a bug fix or workaround needed in perl itself.

The CPANtesters reports for Test-Vars are not consistently showing failures; only 4 runs on Linux are doing so. Just now, I was able to install Test::Vars against Perl 5 blead at 8975221 on FreeBSD-12 -- but when I then tried to install App::perlvars against that same perl, I got failures similar to those being reported at http://matrix.cpantesters.org/?dist=App-perlvars+0.000004.

Hence, patching Test::Vars might not be part of the resolution of this ticket.

I can, however, confirm that 9fdd7fc is the breaking commit for App::perlvars.

@oalders
Copy link
Contributor

oalders commented Sep 7, 2022

I think Test::Vars is actually returning more accurate results via blead. One of the test failures for App-perlvars is here:

package Local::Unused;

use strict;
use warnings;

my $foo;

sub bar {
    my $unused;
    my $one;
    my $two;
    my $three;
    my $four = 4;
}

1;

Previously this was reporting that 4 variables were unused. Now it's reporting that there are 5, with my $four = 4; being the variable that was previously not thought to be unused.

To be clear, it's detecting the vars in sub bar as unused. It seems file with my $foo;.

@richardleach
Copy link
Contributor

richardleach commented Sep 7, 2022

I think Test::Vars is actually returning more accurate results via blead.

That's interesting. I wonder if 6f62971 is what made the difference.

In that example, the only thing touched by the PADSV_STORE optimization in blead is the my $four = 4;.

Just so I understand correctly:

it's detecting the vars in sub bar as unused.

Under blead, Test::Vars reports correctly for 'sub bar', or just less broken than before?

It seems file with my $foo;.

That should be detected as unused?

@jkeenan
Copy link
Contributor

jkeenan commented Sep 7, 2022

The documentation for Test::Vars includes this subsection:


MECHANISM
"Test::Vars" is similar to a part of "Test::Perl::Critic", but the mechanism is different.

While "Perl::Critic", the backend of "Test::Perl::Critic", scans the source code as text, this modules scans the compiled opcodes (or AST: abstract syntax tree) using the "B" module. See also "B" and its submodules.


Now I know next to nothing about "compiled opcodes" or abstract syntax trees, but just the sound of that suggests that Test-Vars's functioning and output is going to be very sensitive to changes in Perl's guts. What's weird here is that that sensitivity is not being reported consistently in its own CPANtesters results. Failures are only showing up consistently in a different CPAN distro's CPANtesters results.

Moreover, the criterion for what makes a variable "unused" lies entirely within Test-Vars (or the minds of its author and users). AFAICT, perl itself makes no judgment as to whether a variable is "unused" or not. The string unused does not occur within pod/perldiag.pod.

$ ack -i unused pod/perldiag.pod
$ 

(Note in passing: In this, Perl is different from C. -Wunused-variable is sometimes seen as a build-time warning when compiling perl; see, e.g., #19654.)

So I'm inclined to say that this problem should be reported to https://github.com/houseabsolute/p5-Test-Vars/issues. I further note that Test-Vars is listed as being in need of a new maintainer. Unfortunately, that means there's no clear path forward for App-perlvars.

@oalders
Copy link
Contributor

oalders commented Sep 7, 2022

Moreover, the criterion for what makes a variable "unused" lies entirely within Test-Vars (or the minds of its author and users).

Right. It's essentially useful as a linter. I've discussed it a bit here: https://www.olafalders.com/2022/02/22/finding-unused-perl-variables/ Test::Vars does have some problems and it's in search of a maintainer. I'm not too concerned about App::perlvars breaking because of it. If it just means it finds more unused variables in 5.38 then I can adjust the test suite accordingly when the time comes.

@oalders
Copy link
Contributor

oalders commented Sep 7, 2022

Under blead, Test::Vars reports correctly for 'sub bar', or just less broken than before?

Under blead it gets everything correct for sub bar. Under other versions of perl it misses one case.

It seems file with my $foo;.

That should be detected as unused?

In my mind, yes. But under earlier perl versions it doesn't get detected as unused either. I don't know the internals of Test::Vars well enough to understand if this is even fixable. So I think I would just expect it to miss that case.

@richardleach
Copy link
Contributor

So I'm inclined to say that this problem should be reported to https://github.com/houseabsolute/p5-Test-Vars/issues.

Yes, that's probably best in the first instance, otherwise I'll just be guessing about what's the intended behaviour. I've created houseabsolute/p5-Test-Vars#47 for now.

@demerphq
Copy link
Collaborator

demerphq commented Sep 7, 2022

In my mind, yes.

Didn't you say it was checking the vars in bar()? Makes sense to me it wouldnt be picked up in there.

@oalders
Copy link
Contributor

oalders commented Sep 8, 2022

Didn't you say it was checking the vars in bar()? Makes sense to me it wouldnt be picked up in there.

Test::Vars works on packages, so the optimist in me would hope that all unused variables in the package would be picked up, not just the unused vars in subroutines, but that's unrelated to this particular issue.

@richardleach
Copy link
Contributor

Status update:

@demerphq
Copy link
Collaborator

I see Devel::Caller still has not been patched. Is it abandonware?

@richardleach
Copy link
Contributor

I see Devel::Caller still has not been patched. Is it abandonware?

Not sure, am going to cross-post the patch to https://github.com/pjcj/Devel--Cover in case that's the preferred method.

@richardleach
Copy link
Contributor

I see Devel::Caller still has not been patched. Is it abandonware?

Not sure, am going to cross-post the patch to https://github.com/pjcj/Devel--Cover in case that's the preferred method.

Ignore me. Wrong module in haste!

@richardleach
Copy link
Contributor

I see Devel::Caller still has not been patched. Is it abandonware?

@richardc - are you able to do a release of Devel::Caller to apply https://rt.cpan.org/Ticket/Display.html?id=144051? (Would it make your life easier if I did a PR to https://github.com/richardc/perl-devel-caller?)

demerphq added a commit to demerphq/perl-devel-caller that referenced this issue Jan 27, 2023
This patch is by Richard Leach, who added the new opcodes to perl 5.37.
I am just pushing it because I already had it applied to a git repo
of Devel::Caller.

This fixes Perl/perl5#20114
@demerphq
Copy link
Collaborator

@richardleach I just created richardc/perl-devel-caller#2

I already had it set up in a repo, it was easy to do.

@rjbs
Copy link
Member

rjbs commented Apr 9, 2023

Variable::Magic fixed. Devel::Cover already represented by #19869

@rjbs rjbs closed this as completed Apr 9, 2023
@jkeenan
Copy link
Contributor

jkeenan commented Apr 9, 2023

Variable::Magic fixed. Devel::Cover already represented by #19869

The other CPAN breakage that was of concern in this issue was Devel::Caller, not Devel::Cover. Devel::Caller is still failing its tests.

@jkeenan jkeenan reopened this Apr 9, 2023
@rjbs
Copy link
Member

rjbs commented Apr 9, 2023

Thanks, oops!

@jkeenan
Copy link
Contributor

jkeenan commented Apr 9, 2023

Thanks, oops!

Devel-Caller has not had a new CPAN release in ten years, but is still considered useful enough that it was picking up reverse dependencies as recently as last year. A patch was submitted upstream in https://rt.cpan.org/Ticket/Display.html?id=144051. Does anyone know how to contact upstream maintainer Richard Clamp? @richardc

@richardc
Copy link
Contributor

Hello, this mention showed up in my inbox.

I'll look at that that patch later today.

@rjbs
Copy link
Member

rjbs commented Apr 28, 2023

Re-closed, thanks so much @richardc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BBC Blead Breaks CPAN - changes in blead broke a cpan module(s) Not a Release Blocker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants