lua-users home
lua-l archive

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



On 1-Jun-06, at 2:38 PM, Roberto Ierusalimschy wrote:

Are there any guarantees made with regard to the validity of pointers
inside Lua code? That is, suppose we look at luaV_execute -- is the
TProtoFunc* guaranteed to be valid after the luaV_execute call
finishes, or are internal pointers (which are derived from
lua_Object's) liable to be garbage collected like everything else?

Lua code does not bother to clear pointers it is not going to use
again, and/or to correct them before it needs. So there are several
places along the code where pointers may be invalid. For instance, in
luaV_execute there are several calls that potentially may reallocate the stack and therefore invalidate 'ra'. But 'ra' is corrected only when/if
needed.

What about, in particular, a TProtoFunc* used in luaV_execute (recall I'm still in the world of Lua 3.1)? Will that pointer (and the underlying members like the function's bytecode, constants, etc.) be valid after luaV_execute completes?


-- Roberto