develooper Front page | perl.perl5.porters | Postings from September 2018

[perl #133518] svref_2object regression in 5.28.0 when accessing tomain::BEGIN CV

Thread Next
From:
Atoomic
Date:
September 14, 2018 18:13
Subject:
[perl #133518] svref_2object regression in 5.28.0 when accessing tomain::BEGIN CV
Message ID:
rt-4.0.24-29956-1536948804-390.133518-75-0@perl.org
# New Ticket Created by  Atoomic 
# Please include the string:  [perl #133518]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133518 >


This is a bug report for perl from atoomic@cpan.org,
generated with the help of perlbug 1.40 running under perl 5.26.1.


-----------------------------------------------------------------
[Please describe your issue here]

svref_2object regression in 5.28.0 when accessing to main::BEGIN CV

With this simple oneliner which tries to access to the CV from the
main::BEGIN GV,
I can notice a regression on 5.28.0 compare to 5.26.0

perl5.28.0 -e 'use B qw(svref_2object); my $gv; eval q{ $gv =
svref_2object( \*main::BEGIN ) }; print ref($gv->CV) . "\n";'
NULL gp in B::GV::CV at -e line 1.

vs

perl5.26.1 -e 'use B qw(svref_2object); my $gv; eval q{ $gv =
svref_2object( \*main::BEGIN ) }; print ref($gv->CV) . "\n";'
B::SPECIAL

Here is the oneliner in a more readable way, note the importance of the
quoted eval (without it, both can see the GV in the same way)
---
use B qw(svref_2object);
my $gv;
eval q{ $gv = svref_2object( \*main::BEGIN ) };
print ref($gv->CV) . "\n";
----

A git bisect points to that change
https://github.com/Perl/perl5/commit/b66d79a6843486dbfe3a6f0a5fb78ffb86dd82e2

we might need an extra FREETMPS ?

---
commit b66d79a6843486dbfe3a6f0a5fb78ffb86dd82e2
Author: David Mitchell <davem@iabyn.com>
Date:   Mon Aug 22 09:50:43 2016 +0100

    FREETMPS when leaving eval, even when void/dying

    [ This commit was originally added as v5.25.2-77-g214949f then reverted
    by v5.25.2-89-gcc040a9, since it broke Variable::Magic. That
distribution
    has since been fixed, so this fix can be re-applied to blead ]

    When a scope is exited normally (e.g. pp_leavetry, pp_leavesub),
    we do a FREETMPS only in scalar or list context; in void context
    we don't bother for efficiency reasons. Similarly, when there's an
    exception and we unwind to (and then pop) an EVAL context, we haven't
    been bothering to FREETMPS.

    The problem with this in try/eval (exiting normally or via an exception)
    is that it can delay some SVs getting freed until *after* $@ has been
    set. If that freeing calls a destructor which happens to set $@,
    then that overwrites the "real" value of $@.

    For example

        sub DESTROY { eval { die "died in DESTROY"; } }
        eval { bless []; };
        is ($@, "");

    Before this commit, that test would fail because $@ is "died in
DESTROY".

    This commit ensures that leaving an eval/try by whatever means always
    clears the tmps stack before setting $@.

    See http://nntp.perl.org/group/perl.perl5.porters/237380.

    For now, I haven't added a FREETMPS to the other pp_leavefoo()
    void context cases, since I can't think of a case where it would
    matter.
---

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.26.1:

Configured by nicolas at Wed Nov 29 10:26:27 MST 2017.

Summary of my perl5 (revision 5 version 26 subversion 1) configuration:

  Platform:
    osname=darwin
    osvers=15.6.0
    archname=darwin-2level
    uname='darwin nicolas-r.local 15.6.0 darwin kernel version 15.6.0: mon
oct 2 22:20:08 pdt 2017; root:xnu-3248.71.4~1release_x86_64 x86_64 '
    config_args='-de -Dprefix=/usr/local/perl/perls/perl-5.26.1
-Aeval:scriptdir=/usr/local/perl/perls/perl-5.26.1/bin'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)'
    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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
/usr/lib
    libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib
-fstack-protector-strong'


---
@INC for perl 5.26.1:
    /Users/nicolas/.dotfiles/perl-must-have/lib
    /Users/nicolas/perl5/lib/perl5/
    /usr/local/perl/perls/perl-5.26.1/lib/site_perl/5.26.1/darwin-2level
    /usr/local/perl/perls/perl-5.26.1/lib/site_perl/5.26.1
    /usr/local/perl/perls/perl-5.26.1/lib/5.26.1/darwin-2level
    /usr/local/perl/perls/perl-5.26.1/lib/5.26.1

---
Environment for perl 5.26.1:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/nicolas
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=/usr/local/perl/bin:/usr/local/perl/perls/perl-5.26.1/bin:/usr/local/opt/ccache/libexec:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/Users/nicolas/.dotfiles/bin:/Users/nicolas/perl5/bin
    PERL5DB=use Devel::NYTProf

PERL5LIB=/Users/nicolas/.dotfiles/perl-must-have/lib:/Users/nicolas/perl5/lib/perl5/
    PERLBREW_BASHRC_VERSION=0.80
    PERLBREW_HOME=/Users/nicolas/.perlbrew
    PERLBREW_MANPATH=/usr/local/perl/perls/perl-5.26.1/man
    PERLBREW_PATH=/usr/local/perl/bin:/usr/local/perl/perls/perl-5.26.1/bin
    PERLBREW_PERL=perl-5.26.1
    PERLBREW_ROOT=/usr/local/perl
    PERLBREW_VERSION=0.84
    PERL_BADLANG (unset)
    PERL_CPANM_OPT=--quiet
    SHELL=/usr/local/bin/zsh


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About