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 */

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?

--Geoff






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to