develooper Front page | perl.perl5.porters | Postings from March 2008

[perl #52284] Segfault in B::SVOP::sv

Thread Previous
From:
inferno @ wboys . ru
Date:
March 31, 2008 03:53
Subject:
[perl #52284] Segfault in B::SVOP::sv
Message ID:
rt-3.6.HEAD-25460-1206931418-1807.52284-75-0@perl.org
# New Ticket Created by  inferno@wboys.ru 
# Please include the string:  [perl #52284]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=52284 >


This is a bug report for perl from inferno@wboys.ru,
generated with the help of perlbug 1.35 running under perl v5.8.8.


-----------------------------------------------------------------
[Please enter your report here]

The following code makes perl to dump core:
====
sub z{
	#must be local
	my ($ref, $self);

	#must be local _and_ initialized
	#here's version from original code
	#but '= (1..3)' suits as well
	my(@keys) = keys(%$ref);

	#these 2 lines must be together
	$ref = $ref->{$keys[0]};
	$self->{rootname} = $keys[0];
}

use B::TerseSize;
#B::debug(undef, 1);
$cv = B::svref_2object(\&{"main::z"});
B::walkoptree_slow($cv->ROOT, "op_size");
====

With uncommented B::debug line, i get:
walkoptree: 0. UNOP (0x8069788) leavesub
  walkoptree: 1. LISTOP (0x8069048) lineseq
     walkoptree: 2. COP (0x8064d88) nextstate
     walkoptree: 2. LISTOP (0x8065fc8) list
       walkoptree: 3. OP (0x8069008) pushmark
       walkoptree: 3. OP (0x8065f48) padsv
       walkoptree: 3. OP (0x8065f88) padsv
     walkoptree: 2. COP (0x8064e08) nextstate
     walkoptree: 2. BINOP (0x80692c8) aassign
       walkoptree: 3. UNOP (0x8069248) null
          walkoptree: 4. OP (0x8069288) pushmark
          walkoptree: 4. UNOP (0x8069148) keys
            walkoptree: 5. UNOP (0x8069108) rv2hv
               walkoptree: 6. OP (0x80690c8) padsv
       walkoptree: 3. UNOP (0x80691c8) null
          walkoptree: 4. OP (0x8069208) pushmark
          walkoptree: 4. OP (0x8069088) padav
     walkoptree: 2. COP (0x8064e88) nextstate
     walkoptree: 2. BINOP (0x80694c8) sassign
       walkoptree: 3. BINOP (0x8069488) helem
          walkoptree: 4. UNOP (0x8069448) rv2hv
            walkoptree: 5. OP (0x8069348) padsv
          walkoptree: 4. UNOP (0x8069408) null
            walkoptree: 5. SVOP (0x8069388) aelemfast

When trying to detect op size for the last SVOP (inside B::Size)
==
sub B::SVOP::size {
    B::Sizeof::SVOP + shift->sv->size;
}
==

code "shift->sv" makes perl coredump

Unfortunatelly, i'm not familiar with XS, so couldn't debug deeper into the
B.xs module.

Here is stack trace from gdb:
#0  0x282ddc09 in make_sv_object (arg=0x82071c8, sv=0x55555555) at B.xs:231
#1  0x282e3d9f in XS_B__SVOP_sv (cv=0x80f9c68) at B.c:2007
#2  0x28113f88 in Perl_pp_entersub () at pp_hot.c:2913
#3  0x280f3ecb in Perl_runops_debug () at dump.c:1459
#4  0x28099066 in S_run_body (oldscope=1) at perl.c:2366
#5  0x28098b2a in perl_run (my_perl=0x804d030) at perl.c:2283
#6  0x08049130 in main ()

PS:
Original line that leads to segfault is as simple as 
perl -e 'use XML::Simple; use B::TerseSize; B::TerseSize::package_size("XML::Simple")'


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.8.8:

Configured by game at Sun Mar 30 09:52:08 MSD 2008.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=freebsd, osvers=6.1-release, archname=i386-freebsd-64int
    uname='freebsd ru-dealer.com 6.1-release freebsd 6.1-release #0: sun may 7 04:42:56 utc 2006 root@opus.cse.buffalo.edu:usrobjusrsrcsyssmp i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-g -DDEBUGGING -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
    optimize='-g',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
    ccversion='', gccversion='3.4.4 [FreeBSD] 20050518', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -Wl,-E -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lgdbm -lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    defined-or

---
@INC for perl v5.8.8:
    /usr/local/lib/perl5/5.8.8/BSDPAN
    /usr/local/lib/perl5/site_perl/5.8.8/mach
    /usr/local/lib/perl5/site_perl/5.8.8
    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/5.8.8/mach
    /usr/local/lib/perl5/5.8.8
    .

---
Environment for perl v5.8.8:
    HOME=/home/game
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/game/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/zsh


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