develooper Front page | perl.perl5.porters | Postings from August 2019

[perl #134336] perl XS: newSVpvf sometimes appends gratuitous '0'

Thread Previous
From:
rwfranks@acm.org
Date:
August 3, 2019 12:55
Subject:
[perl #134336] perl XS: newSVpvf sometimes appends gratuitous '0'
Message ID:
rt-4.0.24-32100-1564836937-1662.134336-75-0@perl.org
# New Ticket Created by  rwfranks@acm.org 
# Please include the string:  [perl #134336]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=134336 >


This is a bug report for perl from rwfranks@acm.org,
generated with the help of perlbug 1.41 running under perl 5.30.0.


-----------------------------------------------------------------

Assume that an XS module contains the following code fragment intended
to return the content of a #define

    /*  #include <openssl/opensslv.h>   */
        #define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1c  28 May 2019"

    MODULE XS::Example

    PROTOTYPES: ENABLE

    SV*
    OpenSSLversion(void)
        CODE:
            RETVAL = newSVpvf( "%s", OPENSSL_VERSION_TEXT );
        OUTPUT:
            RETVAL

This almost always returns the unmodified content of the #define


However, if used with LibreSSL, something strange happens...

        #define OPENSSL_VERSION_TEXT "LibreSSL 2.9.0"

the string returned by OpenSSLversion is "LibreSSL 2.9.00"


After fruitless attempts to repackage the problem in various ways,
I arrived at the conclusion that the fault lies in newSVpvf itself.

One might expect that reducing the code to a degenerate case

            RETVAL = newSVpvf( "LibreSSL 2.9.0" );

would avoid the problem, there being no explicit formatting involved.

Surprise!  It does not, newSVpvf still returns "LibreSSL 2.9.00"

-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.30.0:

Configured by rwf at Mon Jun 10 22:05:41 BST 2019.

Summary of my perl5 (revision 5 version 30 subversion 0) configuration:

  Platform:
    osname=linux
    osvers=5.1.7-300.fc30.x86_64
    archname=x86_64-linux
    uname='linux localhost.localdomain 5.1.7-300.fc30.x86_64 #1 smp
wed jun 5 12:32:28 utc 2019 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de
-Dprefix=/home/rwf/perl5/perlbrew/perls/perl-5.30.0
-Aeval:scriptdir=/home/rwf/perl5/perlbrew/perls/perl-5.30.0/bin'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fwrapv -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O2'
    cppflags='-fwrapv -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='9.1.1 20190503 (Red Hat 9.1.1-1)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64
/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lpthread -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.29.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.29'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'


---
@INC for perl 5.30.0:
    /home/rwf/perl5/lib/perl5
    /home/rwf/perl5/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0/x86_64-linux
    /home/rwf/perl5/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0
    /home/rwf/perl5/perlbrew/perls/perl-5.30.0/lib/5.30.0/x86_64-linux
    /home/rwf/perl5/perlbrew/perls/perl-5.30.0/lib/5.30.0

---Environment for perl 5.30.0:
    HOME=/home/rwf
    LANG=en_GB.utf8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/rwf/perl5/perlbrew/bin:/home/rwf/perl5/perlbrew/perls/perl-5.30.0/bin:/home/rwf/perl5/bin:/home/rwf/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/rwf/.local/bin:/home/rwf/bin:/usr/sbin:/sbin
    PERL5LIB=/home/rwf/perl5/lib/perl5
    PERLBREW_BASHRC_VERSION=0.80
    PERLBREW_HOME=/home/rwf/.perlbrew
    PERLBREW_LIB=
    PERLBREW_MANPATH=/home/rwf/perl5/perlbrew/perls/perl-5.30.0/man
    PERLBREW_PATH=/home/rwf/perl5/perlbrew/bin:/home/rwf/perl5/perlbrew/perls/perl-5.30.0/bin
    PERLBREW_PERL=perl-5.30.0
    PERLBREW_ROOT=/home/rwf/perl5/perlbrew
    PERLBREW_SKIP_INIT=1
    PERLBREW_VERSION=0.86
    PERL_BADLANG (unset)
    PERL_LOCAL_LIB_ROOT=/home/rwf/perl5
    PERL_MB_OPT=--install_base /home/rwf/perl5
    PERL_MM_OPT=INSTALL_BASE=/home/rwf/perl5
    SHELL=/bin/bash


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