develooper Front page | perl.perl5.porters | Postings from October 2011

[perl #102586] version->new("version") SEGVs

Thread Previous | Thread Next
Nicholas Clark
October 31, 2011 08:08
[perl #102586] version->new("version") SEGVs
Message ID:
# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #102586]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.39 running under perl 5.15.4.

[Please describe your issue here]

Perl_new_version() is being caught out by the fact that sv_derived_from()
can return true for a non-object.

$ ./perl -Ilib -e 'version->new("version")'Assertion failed: (SvTYPE(hv) == SVt_PVHV), function Perl_hv_common, file hv.c, line 352.
Abort trap

Perl_xs_version_bootcheck() has a similar problem:

$ ./perl -Ilib -e '$::{"1.11::"} = $::{"version::"}; require Fcntl'
Invalid version object at lib/ line 66.
Compilation failed in require at -e line 1.

This patch seems to fix the problems above. I'm not sure if it's either
complete or correct.

diff --git a/util.c b/util.c
index 221dee5..882086b 100644
--- a/util.c
+++ b/util.c
@@ -4857,7 +4857,7 @@ Perl_new_version(pTHX_ SV *ver)
     SV * const rv = newSV(0);
-    if ( sv_derived_from(ver,"version") ) /* can just copy directly */
+    if ( SvROK(ver) && sv_derived_from(ver,"version") ) /* can just copy directly */
 	I32 key;
 	AV * const av = newAV();
@@ -6429,7 +6429,7 @@ Perl_xs_version_bootcheck(pTHX_ U32 items, U32 ax, const char *xs_p,
     if (sv) {
 	SV *xssv = Perl_newSVpvn_flags(aTHX_ xs_p, xs_len, SVs_TEMP);
-	SV *pmsv = sv_derived_from(sv, "version")
+	SV *pmsv = SvROK(sv) && sv_derived_from(sv, "version")
 	    ? sv : sv_2mortal(new_version(sv));
 	xssv = upg_version(xssv, 0);
 	if ( vcmp(pmsv,xssv) ) {

Nicholas Clark

[Please do not change anything below this line]
Site configuration information for perl 5.15.4:

Configured by nick at Mon Oct 31 11:25:06 GMT 2011.

Summary of my perl5 (revision 5 version 15 subversion 4) configuration:
  Commit id: 3ea0c581844689aba7e3d1f0effa285f332662f4
    osname=darwin, osvers=10.8.0, archname=darwin-2level
    uname='darwin mouse-mill.local 10.8.0 darwin kernel version 10.8.0: tue jun 7 16:33:36 pdt 2011; root:xnu-1504.15.3~1release_i386 i386 '
    config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dinc_version_list=  -Dinc_version_list_init=0 -Dstatic_ext=Fcntl -DDEBUGGING -Doptimize=-g -Uusethreads -Uuse64bitall -Uuselongdouble -Uusemymalloc -Duseperlio -Dprefix=~/Sandpit/snap5.9.x-v5.15.4-107-ga1da11a-i -Dinstallman1dir=none -Dinstallman3dir=none -Dusevendorprefix -Dvendorprefix=~/Sandpit/vendor -Uuserelocatableinc -Ud_dosuid -Uuseshrplib -de -Accccflags=-fcatch-undefined-behavior -Accflags=-DNO_MATHOMS -Umad'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='ccache gcc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -DNO_MATHOMS -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -DNO_MATHOMS -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5666) (dot 3)', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'

Locally applied patches:

@INC for perl 5.15.4:

Environment for perl 5.15.4:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About