Skip to content

B::Deparse generated code affected by use vars? #16238

Closed

Description

@p5pRT

Migrated from rt.perl.org#132429 (status was 'resolved')

Searchable as RT132429$

Activity

  1. p5pRT commented on Nov 11, 2017

    @p5pRT
    Author

    From @toddr

    Created by @toddr

    I discovered that the removal of 'use vars' from B​::Deparse affects
    the WARNINGS_BITS of deparsed code. I think the attached patch
    actually makes for a more pristine deparse.

    Perl Info
    
    Flags:
        category=library
        severity=low
        module=B::Deparse
    
    Site configuration information for perl 5.27.6:
    
    Configured by root at Fri Nov 10 21:43:02 CST 2017.
    
    Summary of my perl5 (revision 5 version 27 subversion 6) configuration:
      Commit id: 8d6363863eb2ae5eb05a83c01c276a321727c828
      Platform:
        osname=linux
        osvers=3.10.0-693.2.2.el7.x86_64
        archname=x86_64-linux-thread-multi
        uname='linux toddr.dev.cpanel.net 3.10.0-693.2.2.el7.x86_64 #1 smp
    tue sep 12 22:26:13 utc 2017 x86_64 x86_64 x86_64 gnulinux '
        config_args='-des -Dusedevel -Uversiononly -Dcc=gcc -Dusethreads
    -Dprefix= -DDEBUGGING'
        hint=recommended
        useposix=true
        d_sigaction=define
        useithreads=define
        usemultiplicity=define
        use64bitint=define
        use64bitall=define
        uselongdouble=undef
        usemymalloc=n
        default_inc_excludes_dot=define
        bincompat5005=undef
      Compiler:
        cc='gcc'
        ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -DDEBUGGING
    -fno-strict-aliasing -pipe -fstack-protector-strong
    -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
    -D_FORTIFY_SOURCE=2'
        optimize='-O2 -g'
        cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -DDEBUGGING
    -fno-strict-aliasing -pipe -fstack-protector-strong
    -I/usr/local/include'
        ccversion=''
        gccversion='4.8.5 20150623 (Red Hat 4.8.5-16)'
        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='gcc'
        ldflags =' -fstack-protector-strong -L/usr/local/lib'
        libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64
    /lib /lib64 /usr/lib64 /usr/local/lib64
        libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
        perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
        libc=libc-2.17.so
        so=so
        useshrplib=false
        libperl=libperl.a
        gnulibc_version='2.17'
      Dynamic Linking:
        dlsrc=dl_dlopen.xs
        dlext=so
        d_dlsymun=undef
        ccdlflags='-Wl,-E'
        cccdlflags='-fPIC'
        lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector-strong'
    
    
    
    @INC for perl 5.27.6:
        /root/projects/perl/lib
        /usr/local/lib/perl5/site_perl/5.27.6/x86_64-linux-thread-multi
        /usr/local/lib/perl5/site_perl/5.27.6
        /usr/local/lib/perl5/5.27.6/x86_64-linux-thread-multi
        /usr/local/lib/perl5/5.27.6
    
    
    Environment for perl 5.27.6:
        HOME=/root
        LANG=en_US.UTF-8
        LANGUAGE (unset)
        LD_LIBRARY_PATH=/root/projects/perl
        LOGDIR (unset)
        PATH=/bin
        PERL_BADLANG (unset)
        SHELL=/bin/zsh
    
    
  2. p5pRT commented on Nov 11, 2017

    @p5pRT
    Author

    From @toddr

    0001-Remove-use-vars-from-B-Deparse.patch
    From 7a0d115e87d52694a2eb0b5de6406b55f91762b9 Mon Sep 17 00:00:00 2001
    From: Todd Rinaldo <toddr@cpan.org>
    Date: Fri, 10 Nov 2017 23:01:27 -0600
    Subject: [PATCH] Remove use vars from B::Deparse
    
    ---
     lib/B/Deparse.pm | 2 +-
     lib/B/Deparse.t  | 4 ++--
     2 files changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
    index 7609d638ee..71fd4a7d3a 100644
    --- a/lib/B/Deparse.pm
    +++ b/lib/B/Deparse.pm
    @@ -53,7 +53,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
     
     $VERSION = '1.45';
     use strict;
    -use vars qw/$AUTOLOAD/;
    +our $AUTOLOAD;
     use warnings ();
     require feature;
     
    diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
    index d94d7f61da..833f0a7853 100644
    --- a/lib/B/Deparse.t
    +++ b/lib/B/Deparse.t
    @@ -1996,7 +1996,7 @@ no warnings "experimental::lexical_subs";
     my sub f {}
     print f();
     >>>>
    -BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"}
    +BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x15"}
     my sub f {
         
     }
    @@ -2009,7 +2009,7 @@ no warnings 'experimental::lexical_subs';
     state sub f {}
     print f();
     >>>>
    -BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"}
    +BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x15"}
     state sub f {
         
     }
    -- 
    2.15.0
    
    
  3. p5pRT commented on Nov 13, 2017

    @p5pRT
    Author

    From @toddr

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

    I discovered that the removal of 'use vars' from B​::Deparse affects
    the WARNINGS_BITS of deparsed code. I think the attached patch
    actually makes for a more pristine deparse.

    It looks like this bit is coming from warnings​::register as called from use vars, which means it's desirable to remove use vars from B​::Deparse.

    BEFORE​:

    $>perl -E'use warnings​::register; use warnings; BEGIN { printf("%x", $_) foreach unpack("C*", ${^WARNING_BITS}) } print "\n\n"'
    5555555555555555555555555555555555

    AFTER​:

    $>perl -E'use warnings; BEGIN { printf("%x", $_) foreach unpack("C*", ${^WARNING_BITS}) } print "\n\n"'
    5555555555555555555555555555555515

  4. p5pRT commented on Nov 15, 2017

    @p5pRT
    Author

    From @toddr

    Merged to blead in commit 1218f5b

  5. p5pRT commented on Nov 15, 2017

    @p5pRT
    Author

    @toddr - Status changed from 'new' to 'pending release'

  6. p5pRT commented on Jun 23, 2018

    @p5pRT
    Author

    From @khwilliamson

    Thank you for filing this report. You have helped make Perl better.

    With the release yesterday of Perl 5.28.0, this and 185 other issues have been
    resolved.

    Perl 5.28.0 may be downloaded via​:
    https://metacpan.org/release/XSAWYERX/perl-5.28.0

    If you find that the problem persists, feel free to reopen this ticket.

  7. p5pRT commented on Jun 23, 2018

    @p5pRT
    Author

    @khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions