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

[perl #118775] sv_vcatpvfn_flags and format string friends crash on numbered args

Thread Next
From:
bulk88
Date:
July 5, 2013 21:55
Subject:
[perl #118775] sv_vcatpvfn_flags and format string friends crash on numbered args
Message ID:
rt-3.6.HEAD-2552-1373061301-1252.118775-75-0@perl.org
# New Ticket Created by  bulk88 
# Please include the string:  [perl #118775]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=118775 >


This is a bug report for perl from bulk88@hotmail.com,
generated with the help of perlbug 1.39 running under perl 5.19.2.


-----------------------------------------------------------------
[Please describe your issue here]

Per 
http://perl5.git.perl.org/perl.git/blob/6de85bb45a5ea25528026a26cac854ee4dcdcd45:/sv.c#l10452 
perl's internal printf supports numbered index format string args. When 
I try to use them, for example
____________________________________________________
SV *
MakeFString()
CODE:
    RETVAL = newSVpvf("%3$d %2$d %1$s", "Just another perl hacker", 2, 3);
OUTPUT:
    RETVAL
____________________________________________________
perl -MLocal::XS -e"print(Local::XS::MakeFString())"
____________________________________________________
I get a crash in strlen() "Unhandled exception at 0x7c362849 
(msvcr71.dll) in perl.exe: 0xC0000005: Access violation reading location 
0x00000003.".
____________________________________________________
 >    msvcr71.dll!strlen()  Line 66    Asm
     perl519.dll!Perl_sv_vcatpvfn_flags(interpreter * 
my_perl=0x003642a4, sv * const sv=0x00368e44, const char * const 
pat=0x00386600, const unsigned int patlen=0, char * * const 
args=0x0012fac8, sv * * const svargs=0x00000000, const long svmax=0, 
char * const maybe_tainted=0x00000000, const unsigned long flags=0)  
Line 10803 + 0x6    C
     perl519.dll!Perl_sv_vsetpvfn(interpreter * my_perl=0x003642a4, sv * 
const sv=0x00368e44, const char * const pat=0x00386600, const unsigned 
int patlen=14, char * * const args=0x0012fac8, sv * * const 
svargs=0x00000000, const long svmax=0, char * const 
maybe_tainted=0x00000000)  Line 10182 + 0x1f    C
     perl519.dll!Perl_vnewSVpvf(interpreter * my_perl=0x003642a4, const 
char * const pat=0x00386600, char * * const args=0x0012fac8)  Line 8859 
+ 0x29    C
     perl519.dll!Perl_newSVpvf_nocontext(const char * const 
pat=0x00386600, ...)  Line 8819 + 0xd    C
     XS.dll!XS_Local__XS_MakeFString(interpreter * my_perl=0x003642a4, 
cv * cv=0x009fdcec)  Line 3520    C
     perl519.dll!Perl_pp_entersub(interpreter * my_perl=0x00000003)  
Line 2878    C
     perl519.dll!Perl_runops_standard(interpreter * my_perl=0x003642a4)  
Line 42 + 0x4    C
     perl519.dll!S_run_body(interpreter * my_perl=0x00000003, long 
oldscope=1)  Line 2495 + 0xa    C
     perl519.dll!perl_run(interpreter * my_perl=0x003642a4)  Line 2411 + 
0x8    C
     perl519.dll!RunPerl(int argc=3, char * * argv=0x01362cf0, char * * 
env=0x00363308)  Line 270 + 0x6    C
     perl.exe!mainCRTStartup()  Line 398 + 0xe    C
     kernel32.dll!_BaseProcessStart@4()  + 0x23    
___________________________________________________

line 10803 is
___________________________________________________
    case 's':
        if (vectorize)
        goto unknown;
        if (args) {
        eptr = va_arg(*args, char*);
        if (eptr)
            elen = strlen(eptr);<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        else {
            eptr = (char *)nullstr;
            elen = sizeof nullstr - 1;
        }
________________________________________________

I *guess* (correct me if I am wrong) numbered args are only implemented 
for "svargs", not "args" based on
http://perl5.git.perl.org/perl.git/commit/211dfcf14199529e353c08dea10d7050e6a4a22a?f=sv.c 
and 
http://perl5.git.perl.org/perl.git/blobdiff/e9c6cca7affc8f1a686236b954e87e5fa39d5127..eb3fce905f8436bbc374998ec8c7c34ce2b73e4e:/sv.c 
.

I would like the numbered args to work for C stack varargs too, so my 
XSUB above works instead of crashes.

I'm not sure if this is a bug report, feature request, doc request, or 
I'm writing the format specifier wrong (a help request).

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

Configured by Owner at Fri Jul  5 11:41:39 2013.

Summary of my perl5 (revision 5 version 19 subversion 2) configuration:
  Derived from: e06f856f7209ef9f86a20d46b2c039a3c7852762
  Platform:
    osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -DWIN32 
-D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT 
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
    optimize='-O1 -MD -Zi -DNDEBUG -GL',
    cppflags='-DWIN32'
    ccversion='13.10.6030', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', 
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-ltcg  -libpath:"c:\perl517\lib\CORE"  -machine:x86'
    libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib"
    libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib 
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl519.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf -ltcg  -libpath:"c:\perl517\lib\CORE"  -machine:x86'

Locally applied patches:
    uncommitted-changes
    253975a33d050576764c52847be36f0c20359d8d

---
@INC for perl 5.19.2:
    C:/perl517/site/lib
    C:/perl517/lib
    .

---
Environment for perl 5.19.2:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\perl517\bin;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET 
2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\Tools\bin\prerelease;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;
    PERL_BADLANG (unset)
    SHELL (unset)


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