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

B module use freed sv #16539

Closed
p5pRT opened this issue Apr 28, 2018 · 7 comments
Closed

B module use freed sv #16539

p5pRT opened this issue Apr 28, 2018 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 28, 2018

Migrated from rt.perl.org#133159 (status was 'rejected')

Searchable as RT133159$

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2018

From damien-43@gmx.fr

Created by damien-43@gmx.fr

Hi
B module does not work with constants sv if it is created in eval 'string'.

% cat t.pl
use v5.26;
use B;

eval '
  $_ = B​::svref_2object(\"foo");
  p($_);
';
say "=" x 80;

p($_);

sub p {
  my $pv = shift;
  printf "PVX = '%s'\n", $pv->PVX;
  printf "CUR = %d\n", $_->CUR;
  printf "LEN = %d\n", $pv->LEN;
  printf "FLAGS = %d\n", $pv->FLAGS;
  printf "SvTYPE = %d\n", $pv->SvTYPE;
  say ref $pv->object_2svref;
}

% perl t.pl
PVX = 'foo'
CUR = 3
LEN = 10
FLAGS = 402736131
SvTYPE = 3
SCALAR

PVX = '��V�U'
CUR = 0
LEN = 94516509793920
FLAGS = 255
SvTYPE = 255
UNKNOWN
[1] 17092 segmentation fault (core dumped) perl t.pl

Perl Info

Flags:
    category=library
    severity=low
    module=B

Site configuration information for perl 5.26.2:

Configured by builduser at Wed Apr 18 22:20:25 CEST 2018.

Summary of my perl5 (revision 5 version 26 subversion 2) configuration:
   
  Platform:
    osname=linux
    osvers=4.15.15-1-arch
    archname=x86_64-linux-thread-multi
    uname='linux flo-64 4.15.15-1-arch #1 smp preempt sat mar 31 23:59:25 utc 2018 x86_64 gnulinux '
    config_args='-des -Dusethreads -Duseshrplib -Doptimize=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Dprefix=/usr -Dvendorprefix=/usr -Dprivlib=/usr/share/perl5/core_perl -Darchlib=/usr/lib/perl5/5.26/core_perl -Dsitelib=/usr/share/perl5/site_perl -Dsitearch=/usr/lib/perl5/5.26/site_perl -Dvendorlib=/usr/share/perl5/vendor_perl -Dvendorarch=/usr/lib/perl5/5.26/vendor_perl -Dscriptdir=/usr/bin/core_perl -Dsitescript=/usr/bin/site_perl -Dvendorscript=/usr/bin/vendor_perl -Dinc_version_list=none -Dman1ext=1perl -Dman3ext=3perl -Dcccdlflags='-fPIC' -Dlddlflags=-shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Dldflags=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
    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='cc'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -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='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='7.3.1 20180312'
    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,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include-fixed /usr/lib /lib/../lib /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.26.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.26'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.26/core_perl/CORE'
    cccdlflags='-fPIC'
    lddlflags='-shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.26.2:
    /home/damien/.local/lib/perl5/x86_64-linux-thread-multi
    /home/damien/.local/lib/perl5
    /usr/lib/perl5/5.26/site_perl
    /usr/share/perl5/site_perl
    /usr/lib/perl5/5.26/vendor_perl
    /usr/share/perl5/vendor_perl
    /usr/lib/perl5/5.26/core_perl
    /usr/share/perl5/core_perl


Environment for perl 5.26.2:
    HOME=/home/damien
    LANG=fr_FR.UTF-8
    LANGUAGE (unset)
    LC_MESSAGES=
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/damien/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
    PERL5LIB=/home/damien/.local/lib/perl5
    PERL_BADLANG (unset)
    PERL_MB_OPT=--install_base "/home/damien/.local"
    PERL_MM_OPT=INSTALL_BASE=/home/damien/.local
    SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented May 7, 2018

From @jkeenan

On Sat, 28 Apr 2018 17​:53​:50 GMT, damien-43@​gmx.fr wrote​:

This is a bug report for perl from damien-43@​gmx.fr,
generated with the help of perlbug 1.40 running under perl 5.26.2.

-----------------------------------------------------------------
[Please describe your issue here]
Hi
B module does not work with constants sv if it is created in eval
'string'.

% cat t.pl
use v5.26;
use B;

eval '
$_ = B​::svref_2object(\"foo");
p($_);
';
say "=" x 80;

p($_);

sub p {
my $pv = shift;
printf "PVX = '%s'\n", $pv->PVX;
printf "CUR = %d\n", $_->CUR;
printf "LEN = %d\n", $pv->LEN;
printf "FLAGS = %d\n", $pv->FLAGS;
printf "SvTYPE = %d\n", $pv->SvTYPE;
say ref $pv->object_2svref;
}

% perl t.pl
PVX = 'foo'
CUR = 3
LEN = 10
FLAGS = 402736131
SvTYPE = 3
SCALAR

PVX = '��V�U'
CUR = 0
LEN = 94516509793920
FLAGS = 255
SvTYPE = 255
UNKNOWN
[1] 17092 segmentation fault (core dumped) perl t.pl

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=library
severity=low
module=B
---
Site configuration information for perl 5.26.2​:

I've been able to replicate this in 5.20.3 and 5.24.1. Hence, it was not introduced in the 5.27 development cycle and is not a blocker for 5.28.0.

Thank you very much.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented May 7, 2018

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

@p5pRT
Copy link
Author

p5pRT commented May 13, 2018

From damien-43@gmx.fr

Hi
A another related bug with constants in eval "string"

$ perl -MB -E '(eval q< B​::svref_2object(\*foo) >)->NAME'
[1] 5393 segmentation fault (core dumped) perl ...

@p5pRT
Copy link
Author

p5pRT commented May 29, 2018

From damien-43@gmx.fr

I am realizing which B.pm doesn't refcount the reference.
Sorry for the noise...

This ticket should be closed.

Perhaps, some warnings should be added in top of B documentation to
avoid future mistake?

Thanks!

@p5pRT
Copy link
Author

p5pRT commented May 29, 2018

From @jkeenan

On Tue, 29 May 2018 08​:53​:51 GMT, damien-43@​gmx.fr wrote​:

I am realizing which B.pm doesn't refcount the reference.
Sorry for the noise...

This ticket should be closed.

Perhaps, some warnings should be added in top of B documentation to
avoid future mistake?

Thanks!

Closing per request from original poster.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented May 29, 2018

@jkeenan - Status changed from 'open' to 'rejected'

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

No branches or pull requests

1 participant