lua-users home
lua-l archive

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


> > Maybe we could avoid these workarounds by forcing a full garbage collection
> > upon errors. This could be added to the core or through the libraries.
> > (That is, pcall and other library functions that do protected calls should
> > call lua_gc in case of errors, and user's C code would be recommended
> > to do the same.)
> 
> This won't help in the case of a coroutine dieing due to an error. All
> the objects are left on the its stack so none will be collected so
> long as the coroutine persists.

When the coroutine itself has an error, Lua actually cannot release the
resources, as they may be nedded for stack inspection after the error.

But there is an even worse scenario, where an error in some other
place cause the coroutine to become garbage in the middle of its
execution. None of the proposed solutions solve this, except changing
the entire garbage collection for a "deterministic" one (that is,
reference counting). I don't think this is worth such change.

-- Roberto