lua-users home
lua-l archive

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


> I've assigned this coroutine to global Lua variable. The 
> crashes are still here.
> 
> Is there any method to debug GC crashes except that trying to 
> randomly guess which Lua object got collected?

I am hardly an expert on this, but if it is userdata you suspect then
what I do is make sure all userdata objects have a __gc function
registered in their metatable. Then from that function I print a log
message reporting the address of the object getting collected. I match
this to messages logged when the userdata object is created. I have
found this to help with both problems of objects getting collected when
I don't want them to and the issue of making sure objects are collected
when they should be.

Unfortunately I don't know of a way to track the lifecycle of lua
objects other than userdata. If you can modify the lua source in your
project it might be possible to change the garbage collection code to
report some information on objects as they get collected.

- DC