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

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

Thread Previous | Thread Next
From:
Brian Fraser
Date:
October 31, 2011 08:17
Subject:
Re: [perl #102586] version->new("version") SEGVs
Message ID:
CA+nL+nYEYJ-p0orWSR9N16XZp=WhNTdZ_hsajC7ccsO5fi7Sjw@mail.gmail.com
On Mon, Oct 31, 2011 at 12:08 PM, Nicholas Clark
<perlbug-followup@perl.org>wrote:

> # New Ticket Created by  Nicholas Clark
> # Please include the string:  [perl #102586]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=102586 >
>
>
>
> This is a bug report for perl from nick@ccl4.org,
> 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/Fcntl.pm 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)
>     dVAR;
>     SV * const rv = newSV(0);
>     PERL_ARGS_ASSERT_NEW_VERSION;
> -    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]
> -----------------------------------------------------------------
> ---
> Flags:
>    category=core
>    severity=medium
> ---
> 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
>  Platform:
>    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 -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org-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
>  Compiler:
>    cc='ccache gcc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp
> -DNO_MATHOMS -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector
> -I/opt/local/include',
>    optimize='-g',
>    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
>    gnulibc_version=''
>  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:
>    lib
>
>  /Users/nick/Sandpit/snap5.9.x-v5.15.4-107-ga1da11a-i/lib/perl5/site_perl/5.15.4/darwin-2level
>
>  /Users/nick/Sandpit/snap5.9.x-v5.15.4-107-ga1da11a-i/lib/perl5/site_perl/5.15.4
>    /Users/nick/Sandpit/vendor/lib/perl5/vendor_perl/5.15.4/darwin-2level
>    /Users/nick/Sandpit/vendor/lib/perl5/vendor_perl/5.15.4
>
>  /Users/nick/Sandpit/snap5.9.x-v5.15.4-107-ga1da11a-i/lib/perl5/5.15.4/darwin-2level
>    /Users/nick/Sandpit/snap5.9.x-v5.15.4-107-ga1da11a-i/lib/perl5/5.15.4
>    .
>
> ---
> Environment for perl 5.15.4:
>    DYLD_LIBRARY_PATH (unset)
>    HOME=/Users/nick
>    LANG=en_GB.ISO8859-1
>    LANGUAGE (unset)
>    LD_LIBRARY_PATH (unset)
>    LOGDIR (unset)
>
>  PATH=/opt/local/bin:/opt/local/sbin:/Users/nick/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/sbin:/sbin:/usr/sbin
>    PERL_BADLANG (unset)
>    SHELL=/bin/bash
>
>
There's a couple other uses of sv_derived_from that check for version
objects, like line 618 of universal.c. Should those get the added guards
too?


Thread Previous | 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