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

[perl #114838] Loading Data::Dumper corrupts PL_sv_yes, or changes semantics of !0 at the least

Thread Next
From:
yves orton
Date:
September 11, 2012 03:10
Subject:
[perl #114838] Loading Data::Dumper corrupts PL_sv_yes, or changes semantics of !0 at the least
Message ID:
rt-3.6.HEAD-11172-1347358193-1422.114838-75-0@perl.org
# New Ticket Created by  yves orton 
# Please include the string:  [perl #114838]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=114838 >


This is a bug report for perl from demerphq@gmail.com,
generated with the help of perlbug 1.39 running under perl 5.17.4.


-----------------------------------------------------------------
Loading Data::Dumper on thread enabled perls seems to change the meaning
of !0, possibly indicating that it corrupts PL_sv_yes.

The aritificially high REFCNT demonstrates that we get PL_sv_yes and
PL_sv_no as expected:

$ ~/bleadperl/bin/perl5.17.4 -MDevel::Peek -le'Dump(sub{ \@_ }->(!1,
!0))' 2>&1 | grep "REFCNT"
  REFCNT = 1
    REFCNT = 1
      REFCNT = 2147483648
      REFCNT = 2147483645

Now we load Data::Dumper first, and we see that the !0 case magically changes:

$ ~/bleadperl/bin/perl5.17.4 -MDevel::Peek -MData::Dumper
-le'Dump(sub{ \@_ }->(!1, !0))' 2>&1 | grep "REFCNT"
  REFCNT = 1
    REFCNT = 1
      REFCNT = 2147483648
      REFCNT = 2

A closer inspection of both:
      REFCNT = 2147483645
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
vs
      REFCNT = 2
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)

Shows that other than the refcount and the fact that it is no longer
PL_sv_yes the
returned value is as expected. See
https://github.com/Sereal/Sereal/commit/21a209ea951c3e5df7d7afa468026cdec20d6c29
for the test fail fix in Sereal which lead to this, inside Sereal we test for

sv == &PL_sv_yes

which stops happening if DD is loaded early.

Full Devel::Peek output is here:

$ ~/bleadperl/bin/perl5.17.4 -MDevel::Peek -le'Dump(sub{ \@_ }->(!1, !0))'
SV = IV(0x1126e80) at 0x1126e90
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x1146ce8
  SV = PVAV(0x1128c58) at 0x1146ce8
    REFCNT = 1
    FLAGS = ()
    ARRAY = 0x113ebc8
    FILL = 1
    MAX = 1
    ARYLEN = 0x0
    FLAGS = (REAL)
    Elt No. 0
    SV = PVNV(0x1125cb8) at 0x1124830
      REFCNT = 2147483648
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
      IV = 0
      NV = 0
      PV = 0x7f4105 ""
      CUR = 0
      LEN = 0
    Elt No. 1
    SV = PVNV(0x1125cd8) at 0x1124848
      REFCNT = 2147483645
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
      IV = 1
      NV = 1
      PV = 0x7f4103 "1"
      CUR = 1
      LEN = 0
$ ~/bleadperl/bin/perl5.17.4 -MDevel::Peek -MData::Dumper
-le'Dump(sub{ \@_ }->(!1, !0))'
SV = IV(0x17d1e98) at 0x17d1ea8
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x17d1da0
  SV = PVAV(0x17d3c58) at 0x17d1da0
    REFCNT = 1
    FLAGS = ()
    ARRAY = 0x17e9c08
    FILL = 1
    MAX = 1
    ARYLEN = 0x0
    FLAGS = (REAL)
    Elt No. 0
    SV = PVNV(0x17d0cb8) at 0x17cf830
      REFCNT = 2147483648
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
      IV = 0
      NV = 0
      PV = 0x7f4105 ""
      CUR = 0
      LEN = 0
    Elt No. 1
    SV = PVNV(0x1a42478) at 0x17fff00
      REFCNT = 2
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
      IV = 1
      NV = 1
      PV = 0x19f3bc8 "1"\0
      CUR = 1
      LEN = 16


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

Configured by yorton at Tue Sep 11 10:59:05 CEST 2012.

Summary of my perl5 (revision 5 version 17 subversion 4) configuration:
  Commit id: 3eebda9adef018d9dd8bb23c07514da7a3e65b97
  Platform:
    osname=linux, osvers=3.0.0-12-generic, archname=x86_64-linux-thread-multi
    uname='linux yam 3.0.0-12-generic #20-ubuntu smp fri oct 7
14:56:25 utc 2011 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Doptimize=-g -d -Dusedevel -Dusethreads
-Dprefix=~/bleadperl -Dcc=ccache gcc -Dld=gcc -DDEBUGGING'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.1', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    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 -L/usr/local/lib'
    libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.13'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib
-fstack-protector'

Locally applied patches:


---
@INC for perl 5.17.4:
    /home/yorton/bleadperl/lib/site_perl/5.17.4/x86_64-linux-thread-multi
    /home/yorton/bleadperl/lib/site_perl/5.17.4
    /home/yorton/bleadperl/lib/5.17.4/x86_64-linux-thread-multi
    /home/yorton/bleadperl/lib/5.17.4
    .

---
Environment for perl 5.17.4:
    HOME=/home/yorton
    LANG=en_US.UTF-8
    LANGUAGE=en
    LC_COLLATE=en_US.UTF-8
    LC_CTYPE=en_US.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/yorton/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash


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