[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: custom model rows-reordered marshal



Torsten Schoenfeld wrote:

> Ah, I didn't think of the possibility that the whole stack might be moved.  And
> strangely enough, it doesn't seem to happen for me.  Your test case passes for
> me with only PUTBACK and no SPAGAIN, even when I increase the artificial stack
> size from 500 to 500000.  But I see why it might fail: when the requested stack
> size exceeds the size currently allocated, perl calls something like realloc()
> which might move the whole block.

I adjusted the test case slightly and now see the stack movement too.

> Yeah.  The new rule of thumb then seems to be: if there is a chance that someone
> might overwrite the stack before you return from the xsub, call SPAGAIN before
> and PUTBACK after any code that modifies the local stack pointer.

Or, perhaps better: in a PPCODE xsub which modifies the local stack pointer, use
PUTBACK before and SPAGAIN after any code that might modify the global stack
pointer.
-- 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]