Front page | perl.perl5.porters |
Postings from July 2012
[perl #113438] caller() skips XS funcs
Thread Next
From:
Father Chrysostomos via RT
Date:
July 13, 2012 17:04
Subject:
[perl #113438] caller() skips XS funcs
Message ID:
rt-3.6.HEAD-11172-1342224260-1563.113438-15-0@perl.org
On Wed May 30 13:12:41 2012, bulk88 wrote:
> 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.
I think this is by design. The whole point of XSUBs is that they are
fast because they don’t use the context stack. This also means that
XSUBs can have direct access to the caller’s environment.
--
Father Chrysostomos
---
via perlbug: queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=113438
Thread Next
-
[perl #113438] caller() skips XS funcs
by Father Chrysostomos via RT