On Feb 10, 2010, at 7:32 PM, Private and Confidential wrote: > I've written a callback function for an XS module designed to call a perl > function when invoked. > > If I call the function directly, from within the C code, it runs through > completely as expected. > > If its invoked as a callback from the library I am wrapping, it does > immediately at "dSP;" i.e. SV **sp = PL_stack_sp; > > Specifically PL_stack_sp seems to cause SEGV when touched - I can't even see > the value, printf dies also. > > I can't find anything similar discussed anywhere, does anyone have an idea > what might be happening?
Are there multiple threads involved? If you're cold-calling from C code, you probably need to set up the context properly. This should be mentioned in the perlguts, perlxs, and perlxstut manpages. If you're coming from another thread, then you have considerably more work to do to get the context set up safely for invoking code in the interpreter. -- If the monkey could type one keystroke every nanosecond, the expected waiting time until the monkey types out Hamlet is so long that the estimated age of the universe is insignificant by comparison ... this is not a practical method for writing plays. -- Gian-Carlo Rota