via RT chromatic <[EMAIL PROTECTED]> wrote:

# New Ticket Created by  chromatic
# Please include the string:  [perl #41511]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41511 >


Hi there,

Here's a complex one.  Define a multisub in PIR, then try to call it from
C.
I assume that you get the PMC for the (multi) sub, then use
Parrot_call_sub*() to invoke it.

The problem is that the layout of a Sub PMC is different from the layout
of a
MultiSub PMC, especially when the code tries to do:

    CONTEXT(interp->ctx)->constants =
        PMC_sub(sub)->seg->const_table->constants;

For a normal Sub, PMC_sub(sub)->seg is a pointer.  For a MultiSub,
PMC_sub(sub)->seg is the number of multi variants.  Crash!  Boom!

Removing this code doesn't help, because then it gives argument mismatch
errors.  Similarly, setting this code within invoke() in MultiSub doesn't
seem to avoid the crash either for some reason.

I suspect that there was a similar problem avoided earlier when MultiSubs
first appeared, or that there's a better way to initialize context when
running code from C.

I can provide more code if necessary, unless this looks like an obvious
fix to
someone.


If you wanted to send me some sample code that invoked both a normal sub and
a MultiSub, I'd certainly take a look. I'm pretty sure the whole idea of
invoke-able objects was never really thought out -- some of the logic in
Sub.invoke() should be elsewhere.

--
Matt Diephouse
http://matt.diephouse.com

Reply via email to