develooper Front page | perl.perl5.porters | Postings from July 2013

[perl #118907] [PATCH] Storable: Do not call DESTROY on empty objects with STORABLE_attach

Thread Previous
From:
Vladimir Timofeev
Date:
July 14, 2013 17:52
Subject:
[perl #118907] [PATCH] Storable: Do not call DESTROY on empty objects with STORABLE_attach
Message ID:
rt-3.6.HEAD-2552-1373824300-1981.118907-75-0@perl.org
# New Ticket Created by  Vladimir Timofeev 
# Please include the string:  [perl #118907]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=118907 >


The fix #118829 (leaks in Storable) exposed another problem.
In short Storable calls DESTROY on temrorary "empty" objects with
STORABLE_attach hooks.

First patch fixes it.

commit message:
Before this fix, deserialization process for object with STORABLE_attach
hook looks like:
1. create SV of needed type
2. lookup classname
3. bless SV to class
4. lookup for STORABLE_attach
5. destroy SV
6. return result of STORABLE_attach call
As a result DESTROY method of target class was called with empty, not
initialized object. This behaviour very bad especially for non
hash-based XS objects.

Fix it, by move blessing temprorary SV after STORABLE_attach hook check.

Second should restore speed of deserialization to previous level.

commit message:
Pull out getting stash by name from macro BLESS and SEEN.
So results of gv_stashpv may be reused by calling side. This allow
to not evaluate same things twice in retrieve_hook.

Patches against blead, but work was only on Storable, so test was running with
perl 5.16.3:

Summary of my perl5 (revision 5 version 16 subversion 3) configuration:

  Platform:
    osname=linux, osvers=3.7.10-1-arch, archname=x86_64-linux
    uname='linux vov.home 3.7.10-1-arch #1 smp preempt thu feb 28
09:50:17 cet 2013 x86_64 gnulinux '
    config_args='-de
-Dprefix=/home/vovkasm/perl5/perlbrew/perls/perl-5.16.3 -Dcc=clang
-Dcpp=clang-cpp -Doptimize=-O3 -march=native -g -Uusethreads
-Aeval:scriptdir=/home/vovkasm/perl5/perlbrew/perls/perl-5.16.3/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='clang', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3 -march=native -g',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 Compatible Clang 3.2
(tags/RELEASE_32/final)', 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='clang', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
/lib64 /usr/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/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 -O3 -march=native -g
-L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL
                        USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
  Built under linux
  Compiled at Mar 14 2013 02:59:02
  %ENV:
    PERLBREW_BASHRC_VERSION="0.64"
    PERLBREW_HOME="/home/vovkasm/.perlbrew"
    PERLBREW_MANPATH="/home/vovkasm/perl5/perlbrew/perls/perl-5.16.3/man"
    PERLBREW_PATH="/home/vovkasm/perl5/perlbrew/bin:/home/vovkasm/perl5/perlbrew/perls/perl-5.16.3/bin"
    PERLBREW_PERL="perl-5.16.3"
    PERLBREW_ROOT="/home/vovkasm/perl5/perlbrew"
    PERLBREW_VERSION="0.64"
  @INC:
    /home/vovkasm/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux
    /home/vovkasm/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3
    /home/vovkasm/perl5/perlbrew/perls/perl-5.16.3/lib/5.16.3/x86_64-linux
    /home/vovkasm/perl5/perlbrew/perls/perl-5.16.3/lib/5.16.3
    .

--
Vladimir Timofeev <vovkasm@gmail.com>

Thread Previous


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