develooper Front page | perl.perl5.porters | Postings from May 2012

[perl #113438] caller() skips XS funcs

From:
bulk 88
Date:
May 30, 2012 13:12
Subject:
[perl #113438] caller() skips XS funcs
Message ID:
rt-3.6.HEAD-5009-1338408761-925.113438-75-0@perl.org
# New Ticket Created by  bulk 88 
# Please include the string:  [perl #113438]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=113438 >





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


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

caller() does not see XS functions. Given this XS func.
_________________________________
void
Caller()
PPCODE:
{
    dSP;
    ENTER;
    SAVETMPS;
    PUSHMARK(SP);
    PUTBACK;
    call_pv("main::cb", G_VOID);
    FREETMPS;
    LEAVE;
}
___________________________________
And this test script
__________________________________
use strict;
use Data::Dumper;
use Local::XS;
sub cb {
    print Dumper([caller(0)]);
    print Dumper([caller(1)]);
    print Dumper([caller(2)]);
    print Dumper([caller(3)]);
}
sub root_sub{
Local::XS::Caller();
}

root_sub();
_________________________________

The output is
_________________________________
$VAR1 = [
          "main",
          "C:\\Documents and Settings\\Administrator\\Desktop\\CALLER.PL",
          11,
          "main::cb",
          1,
          undef,
          undef,
          undef,
          1538,
          "\0\0\0\0\0\0\0\0\0\0\0\0\0",
          undef
        ];
$VAR1 = [
          "main",
          "C:\\Documents and Settings\\Administrator\\Desktop\\CALLER.PL",
          14,
          "main::root_sub",
          1,
          undef,
          undef,
          undef,
          1794,
          "\0\0\0\0\0\0\0\0\0\0\0\0\0",
          undef
        ];
$VAR1 = [];
$VAR1 = [];
____________________________________


The output shows caller can't see XS funcs in the call stack. This bug causes Perl code that inspect the call stack to not see the XS func's package or its existence, and therefore see the package of the last pure Perl sub, not any intermediate XS funcs and therefore act on the wrong package. If I take a C debugger to the XS func, and look at "my_perl->Icurcop->cop_stashpv" inside Local::XS::Caller(), it says "main". Caller() XS func is not in main.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.14.2:

Configured by sshd_server at Fri Oct  7 15:14:49 2011.

Summary of my perl5 (revision 5 version 14 subversion 2) configuration:
   
  Platform:
    osname=MSWin32, osvers=5.2, archname=MSWin32-x64-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=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -Ox -GL -fp:precise -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO',
    optimize='-MD -Zi -DNDEBUG -Ox -GL -fp:precise',
    cppflags='-DWIN32'
    ccversion='15.0.30729', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='__int64', ivsize=8, 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:\Perl64\lib\CORE"  -machine:AMD64'
    libpth=\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 bufferoverflowU.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl514.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:\Perl64\lib\CORE"  -machine:AMD64'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY

---
@INC for perl 5.14.2:
    C:/Perl64/site/lib
    C:/Perl64/lib
    .

---
Environment for perl 5.14.2:
    CYGWIN=tty
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64;c:\WINDOWS\Microsoft.NET\Framework64\v3.5;c:\WINDOWS\Microsoft.NET\Framework64\v3.5\Microsoft .NET Framework 3.5 (Pre-Release Version);c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727;c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCPackages;c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools;c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\bin;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\x64;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\win64\x64;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin;C:\Perl64\site\bin;C:\Perl64\bin;C:\sources\GnuWin32\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC;
    PERL_BADLANG (unset)
    PERL_JSON_BACKEND=JSON::XS
    PERL_YAML_BACKEND=YAML
    SHELL (unset)

 		 	   		  




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About