[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: retrieve top-level lua_State?
- From: Sam Roberts <vieuxtech@...>
- Date: Sat, 6 Jun 2009 10:52:56 -0700
On Sat, Jun 6, 2009 at 6:27 AM, David Ludwig<firstname.lastname@example.org> wrote:
> The memory of a coroutine's lua_State can get garbage collected and
> freed automatically, whereas the top-level state's memory will not get
> freed unless specifically asked. This can be a problem if a
> coroutine's code calls a C function, which then records the pointer of
> the passed-in lua_State. If the coroutine ends and its state gets
> freed, the C-side code may end up crashing if it tries to use that
> lua_State. One fix to this is to use the top-level state.
The C code shouldn't be storeing L this long, it should be using the L
passed to it.