lua-users home
lua-l archive

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

On Friday 02, Greg Underwood wrote:
> Finally - In this case lua_tostring() seems to think it is returning a
> string - the value in method_name is a pointer to memory, not NULL, and
> the memory was, just prior to the GC run, a string that contains the next
> token to be processed - AddLight.  But because it's been GC'd, the string
> just has garbage in it.  It seems to me that this is the problem -
> lua_tostring() is, validly, going to return a string, but that string got
> incorrectly Garbage Collected.

It sounds to me that the Lua state is being corrupted.  With no corruption of 
the Lua state it would be impossible for the VM to GC the string if it was on 
the stack for your C code to access.

Try re-compiling the Lua VM with LUA_USE_APICHECK defined in luaconf.h
Also run the problem code under a memory checker like valgrind (I don't know 
the name of a similar tool for windows, but there should be one).

Memory corruption bugs are some of the most difficult bugs to track down, 
since the real bug is hiding somewhere else.

Robert G. Jakabosky