lua-users home
lua-l archive

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


On Sun, Sep 12, 2004 at 07:43:35PM -0500, Matthew Harmon wrote:
> EXCEPT... on occasion, the script seems to be GC'd before I do the unref()
> and it crashes when I get to the unref().  Can anybody give me a hint about
> this.  Am I approaching this totally wrong?

Calling luaL_unref() with a bad reference should not cause a crash. I
suspect that what has actually happened is that your child state
itself has been GCed. You need to make sure a reference to the state
exists, e.g. in the registry, until you have finished with it.

> I managed to solve the problem by creating my references in the "master"
> state, but I'd still like to understand what is going on under the hood.

References are stored in the registry, which is shared between a
'master' and all its children. So, this change is probably just
working around the actual problem by avoiding referring to the
deceased child.

-- Jamie Webb