in reply to Problem on perl callbacks from XS

I don't see a principal problem with the Perl stack and your function getting called again before it has completed, so I suppose the problem lies elsewhere (it's hard to tell though when only seeing a snippet of code taken out of its context).

One potential problem could be that you aren't caring about the return value of call_sv() (which is the number of items returned by the Perl routine). This is dangerous, because if the routine - for whatever reason - leaves a different number of items on the stack than you're expecting/handling (you're handling exactly one item with your POPs), the stack will be messed up...   (not necessarily your problem here, but still something to be aware of).

Replies are listed 'Best First'.
Re^2: Problem on perl callbacks from XS
by cosimo (Hermit) on May 25, 2008 at 08:45 UTC

    Yes, in fact, the complete code contains this:

    int count; ... count = call_sv(..., G_SCALAR); assert(count==1);

    which, AFAIK, should be "safe".