hi all (stas in particular :)
I have this bit of XS in Apache::SSLLookup
SV * new(self, r) SV * self Apache::RequestRec r
INIT: MP_dTHX; /* interpreter selection */
why do you need that? You already have the context, it's pTHX
this turns into the C code
XS(XS_Apache__SSLLookup_new) { dXSARGS; if (items != 2) Perl_croak(aTHX_ "Usage: Apache::SSLLookup::new(self, r)"); { SV * self = ST(0); Apache__RequestRec r = modperl_xs_sv2request_rec(aTHX_ ST(1), "Apache::RequestRec", cv); SV * RETVAL; #line 44 "SSLLookup.xs" MP_dTHX; /* interpreter selection */
which barfs if new() is called with a simple hashref ( {} ) instead of a blessed object ($r or otherwise):
[Switching to thread 3 (process 1102)]#0 0x00e1b727 in modperl_hv_request_find (my_perl=0xa1c9058, in=0xae3ca48, classname=0xdb31a7 "Apache::RequestRec", cv=0xa2f981c) at modperl_util.c:79 79 Perl_croak(aTHX_ (gdb) bt #0 0x00e1b727 in modperl_hv_request_find (my_perl=0xa1c9058, in=0xae3ca48, classname=0xdb31a7 "Apache::RequestRec", cv=0xa2f981c) at modperl_util.c:79 #1 0x00e1b8da in modperl_xs_sv2request_rec (my_perl=0xa1c9058, in=0xae3ca48, classname=0xdb31a7 "Apache::RequestRec", cv=0xa2f981c) at modperl_util.c:131 #2 0x00db21ce in XS_Apache__SSLLookup_new (my_perl=0xa1c9058, cv=0xa2f981c) at SSLLookup.c:49
so, the issue seems to be that this call in modperl_hv_request_find
if (!sv) { Perl_croak(aTHX_ "method `%s' invoked by a `%s' object with no `r' key!",
does not yet have an interpreter context. but we need r to call MP_dTHX, so I'm left with a kind of chicken-and-egg problem here if I want my constructor to be robust - new() with an improper object falls through to different logic and is safe, while new() with no arguments seems to work fine as well (but I'm confused why the XS-generated Perl_croak doesn't core dump in this case, since it also requires a context). of course, it's not a pressing issue, but something that would be nice to address from a completeness standpoint.
anyway, after playing with it for a while, I am out of ideas. thoughts?
Your trace shows that you have the context just fine. Most likely it croaks in one of the macros:
Perl_croak(aTHX_
"method `%s' invoked by a `%s' object with no `r' key!",
cv ? GvNAME(CvGV(cv)) : "unknown",
HvNAME(SvSTASH(SvRV(in))));and not context. expand:
gdb> print *cv gdb> print *in
and descend further to see where the problem is.
Also add at the beginning of the module gets
#define PERL_NO_GET_CONTEXT
to avoid overheads of getting the context and pass it explicitly around.
If you don't figure it out, send me the package and I'll look at it.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
