[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: More lua stack operations support?
- From: Jean-Luc Jumpertz <jean-luc@...>
- Date: Mon, 3 Mar 2014 11:03:23 +0100
Le 3 mars 2014 à 10:17, Dirk Laurie <firstname.lastname@example.org> a écrit :
> If you are returning to Lua, the return values are used and the stack
> is cleaned up.
> So this situation only applies when you staying in C.
Indeed. But in many cases but the simplest ones, it's not uncommon to call C functions from other C functions. :-)
> I find it hard to imagine a situation where stack leakage would be
> critical when you
> have all the resources of C at your disposal.
It is not a matter of "resources of C". The point is to that the stack layout is part of API contract when calling a C function using the Lua API.
And regarding the possible problems caused by stack leakage, the default stack size limit is easily reached
> Maybe you would be able to convince me if you showed an actual
> rather than a hypothetical example.
Easy. Just think of a simple C function returning multiple values that are not produced contiguously in the stack. You'll need to do stack removals (or insertions, both are interchangeable) to have the stack with the correct layout before returning.