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

$@ = 100; die doesn't propagate 100 #17098

Closed
p5pRT opened this issue Jul 17, 2019 · 8 comments
Closed

$@ = 100; die doesn't propagate 100 #17098

p5pRT opened this issue Jul 17, 2019 · 8 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Jul 17, 2019

Migrated from rt.perl.org#134291 (status was 'pending release')

Searchable as RT134291$

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 17, 2019

From @tonycoz

toddr pointed this out in IRC​:

05​:50 < toddr> TonyC after 8b3945e, the output
  of this changed​: perl -e '$@​ = 123; die'
05​:50 < toddr> is that a bug?
05​:51 < toddr> If it's not an IV, then you get different output.

Similarly for NVs.

tony@​mars​:.../git/perl$ ./perl -e '$@​ = 123; die'
Died at -e line 1.
tony@​mars​:.../git/perl$ ./perl -e '$@​ = "123"; die'
123 ...propagated at -e line 1.
tony@​mars​:.../git/perl$ ./perl -e '$@​ = 3.14; die'
Died at -e line 1.

Patch soon

Perl Info

Flags:
    category=core
    severity=medium

Summary of my perl5 (revision 5 version 31 subversion 2) configuration:
  Commit id: 973ae08839a3c974ff88014594ecf63cdb20d5e8
  Platform:
    osname=linux
    osvers=4.9.0-9-amd64
    archname=x86_64-linux
    uname='linux mars 4.9.0-9-amd64 #1 smp debian 4.9.168-1+deb9u3 (2019-06-16) x86_64 gnulinux '
    config_args='-des -Dusedevel -Doptimize=-O0 -g -DDEBUGGING'
    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 ='-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='-O0 -g'
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='6.3.0 20170516'
    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 =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/6/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.24.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.24'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O0 -g -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    DEBUGGING
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_DEVEL
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Locally applied patches:
    uncommitted-changes
  Built under linux
  Compiled at Jul 17 2019 10:48:14
  %ENV:
    PERLBREW_BASHRC_VERSION="0.43"
    PERLBREW_HOME="/home/tony/.perlbrew"
    PERLBREW_MANPATH=""
    PERLBREW_PATH="/home/tony/perl5/perlbrew/bin"
    PERLBREW_ROOT="/home/tony/perl5/perlbrew"
    PERLBREW_VERSION="0.67"
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.31.2/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.31.2
    /usr/local/lib/perl5/5.31.2/x86_64-linux
    /usr/local/lib/perl5/5.31.2

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 17, 2019

From @tonycoz

On Tue, 16 Jul 2019 18​:07​:14 -0700, tonyc wrote​:

Patch soon

Attached.

I'll apply this soon.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 17, 2019

From @tonycoz

0001-perl-134291-propagate-non-PVs-in-in-bare-die.patch
From dac821a895ae3a7d26ea9f9f6b6d2e48592a3fe0 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 17 Jul 2019 11:32:50 +1000
Subject: (perl #134291) propagate non-PVs in $@ in bare die()

---
 pp_sys.c   | 2 +-
 t/op/die.t | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/pp_sys.c b/pp_sys.c
index 0214367ea6..251527785e 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -498,7 +498,7 @@ PP(pp_die)
 		}
 	    }
 	}
-	else if (SvPOK(errsv) && SvCUR(errsv)) {
+	else if (SvOK(errsv) && (SvPV_nomg(errsv,len), len)) {
 	    exsv = sv_mortalcopy(errsv);
 	    sv_catpvs(exsv, "\t...propagated");
 	}
diff --git a/t/op/die.t b/t/op/die.t
index ef2b85f8f5..d6d7daffa5 100644
--- a/t/op/die.t
+++ b/t/op/die.t
@@ -6,7 +6,7 @@ BEGIN {
     set_up_inc('../lib');
 }
 
-plan tests => 20;
+plan tests => 21;
 
 eval {
     eval {
@@ -94,6 +94,10 @@ like($@, qr/\.{3}propagated at/, '... and appends a phrase');
     local $SIG{__WARN__} = sub { $ok = 0 };
     eval { undef $@; die };
     is( $ok, 1, 'no warnings if $@ is undef' );
+
+    eval { $@ = 100; die };
+    like($@."", qr/100\t\.{3}propagated at/,
+         'check non-PVs in $@ are propagated');
 }
 
 TODO: {
-- 
2.11.0

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 17, 2019

From @toddr

Created by @toddr

We noticed today that die will not display $@​ if it's an IV

$>perl -e'$@​ = 123; die'
Died at -e line 1.

$>perl -e'$@​ = "123"; die'
123 ...propagated at -e line 1.

I bisected it to a change just before 5.18​:

8b3945e is the first bad commit
commit 8b3945e
Author​: Tony Cook <tony@​develop-help.com>
Date​: Fri Apr 26 09​:56​:58 2013 +1000

  [perl #117743] don't warn on $@​ = undef; die;

and fix the test that's meant to detect this bug.

:100644 100644 8bf9fa7cf13daf5e5461c945266a9579c5ac0590
04ccddb9ab6a733eb4ac3453f6ccdd3a0a54fbcb M pp_sys.c
:040000 040000 6f31b960f19e960499385dbf0d1b9d96c77841c6
9795097c2f12735bdfd390742047ace3d0dc48ca M t

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.28.0:

Configured by cPanel at Fri Feb 15 18:56:31 CST 2019.

Summary of my perl5 (revision 5 version 28 subversion 0) configuration:

  Platform:
    osname=linux
    osvers=3.10.0-123.20.1.el7.x86_64
    archname=x86_64-linux-64int
    uname='linux rpmbuild-64-centos-7.dev.cpanel.net
3.10.0-123.20.1.el7.x86_64 #1 smp thu jan 29 18:05:33 utc 2015 x86_64
x86_64 x86_64 gnulinux '
    config_args='-des -Dusedevel -Darchname=x86_64-linux-64int
-Dcc=/usr/bin/gcc -Dcpp=/usr/bin/cpp -Dusemymalloc=n -DDEBUGGING=none
-Doptimize=-Os -Accflags=-m64 -Dccflags=-DPERL_DISABLE_PMC -fPIC -DPIC
-Duseshrplib -Duselargefiles=yes -Duseposix=true -Dhint=recommended
-Duseperlio=yes -Dprefix=/usr/local/cpanel/3rdparty/perl/528
-Dsiteprefix=/opt/cpanel/perl5/528 -Dsitebin=/opt/cpanel/perl5/528/bin
-Dsitelib=/opt/cpanel/perl5/528/site_lib -Dusevendorprefix=true
-Dvendorbin=/usr/local/cpanel/3rdparty/perl/528/bin
-Dvendorprefix=/usr/local/cpanel/3rdparty/perl/528/lib/perl5
-Dvendorlib=/usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib
-Dprivlib=/usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0
-Dman1dir=none -Dman3dir=none
-Dscriptdir=/usr/local/cpanel/3rdparty/perl/528/bin
-Dscriptdirexp=/usr/local/cpanel/3rdparty/perl/528/bin
-Dsiteman1dir=none -Dsiteman3dir=none
-Dinstallman1dir=none -Dversiononly=no -Dinstallusrbinperl=no
-Dcf_by=cPanel -Dmyhostname=localhost -Dperladmin=root@localhost
-Dcf_email=support@cpanel.net -DDB_File=true -Ud_dosuid
-Uuserelocatableinc -Umad -Uusethreads -Uusemultiplicity -Uusesocks
-Uuselongdouble -Duse64bitint -Uuse64bitall'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='/usr/bin/gcc'
    ccflags ='-DPERL_DISABLE_PMC -fPIC -DPIC -m64 -fwrapv
-fno-strict-aliasing -pipe -fstack-protector-strong
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-D_FORTIFY_SOURCE=2'
    optimize='-Os'
    cppflags='-DPERL_DISABLE_PMC -fPIC -DPIC -m64 -fwrapv
-fno-strict-aliasing -pipe -fstack-protector-strong
-I/usr/local/include'
    ccversion=''
    gccversion='4.8.2 20140120 (Red Hat 4.8.2-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='/usr/bin/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=true
    libperl=libperl.so
    gnulibc_version='2.17'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E
-Wl,-rpath,/usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0/x86_64-linux-64int/CORE'
    cccdlflags='-fPIC'
    lddlflags='-shared -Os -L/usr/local/lib -fstack-protector-strong'

Locally applied patches:
    cPanel - disable man installs
    cPanel - cPanel INC PATH
    cPanel - Avoid importing symbols unless requested
    cPanel - Disable termcap warning when TERM is unset
    cPanel - Do not warn when close fails because the file handle is
    cPanel - COW Static support
    cPanel - Use dup2 from Cpanel::POSIX::Tiny
    cPanel - Disable 14fileno.t tests since Cpanel::POSIX::Tiny is
    cPanel - Avoid use vars when our will do in Core Perl
    cPanel - add Perl_DeclareStaticMemory
    cPanel - Disable xs handshake
    cPanel - Provide a way to clear swash invlists for B::C
    cPanel - Switch several CPAN modules to XSLoader
    cPanel - BC Static shared memory for single malloc
    cPanel - Hard code frequent Config checks so it's not needed
    cPanel - Storable do not load Fcntl
    cPanel - Optimize File::Find performance for backup metadata
    cPanel - Reduce Scalar::Utils regex overhead
    cPanel - skip shadow call when euid > 0 on linux
    cPanel - Fix warning from Memoize::Expire
    cPanel - =?UTF-8?q?Allow=20=E2=80=9Cpeer=E2=80=9D=20to=20be?=
    cPanel - Remove use vars from Digest::
    cPanel - Remove launcher regex in Config.pm
    cPanel - Change method of generating names for non-existent user
    cPanel - BC extra protection in Perl_sv_vcatpvfn_flags
    cPanel - Fix Getopt::Long version number to be 2.50 not 2.5
    cPanel - Reduce startup size of PL_strtab
    cPanel - Perl_my_setenv(); handle integer wrap
    cPanel - add test for CVE-2018-12015 (RT #133250)
    cPanel - PATCH: [perl #133423
    cPanel - (perl #133314) always close the directory handle on
    cPanel - CPAN::Config use manual install as default for root
    cPanel - Avoid a warning when prompting install_help intro
    cPanel - Avoid a warning from cpan when run with warnings


@INC for perl 5.28.0:
    /usr/local/cpanel
    /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/x86_64-linux-64int
    /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib
    /usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0/x86_64-linux-64int
    /usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0
    /opt/cpanel/perl5/528/site_lib/x86_64-linux-64int
    /opt/cpanel/perl5/528/site_lib


Environment for perl 5.28.0:
    HOME=/root
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/cpanel/bin:/usr/local/cpanel/3rdparty/bin:/usr/local/cpanel/3rdparty/perl/528/bin:/usr/local/cpanel/3rdparty/perl/528/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/cpanel/perl5/528/bin
    PERL_BADLANG (unset)
    PERL_USE_UNSAFE_INC=0
    SHELL=/bin/zsh

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 17, 2019

From nicolas@atoomic.org

this is a duplicate of what was reported and fixed earlier by Tony via RT #134291
this ticket should be close

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 17, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 22, 2019

From @tonycoz

On Tue, 16 Jul 2019 18​:33​:46 -0700, tonyc wrote​:

On Tue, 16 Jul 2019 18​:07​:14 -0700, tonyc wrote​:

Patch soon

Attached.

I'll apply this soon.

Applied as 85d4e0a.

Tony

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 22, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.