lua-users home
lua-l archive

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


This looks very similar to code that I had found to create assertions and crashes.  Have you applied the patch for this problem?  It's available at http://www.lua.org/bugs.html, Lua 5.0.2 bug #3.  After the patch, the assertion may still be triggered, but no crashes should occur.  This bug was discussed earlier in this mailing list.  See http://comments.gmane.org/gmane.comp.lang.lua.general/12835 for details.

On 10/13/05, Martin Stone <martin.stone@evos.net> wrote:
I am getting the following assertion in Lua 5.0.2:

Assertion failed: !iscollectable(o2) || (ttype(o2) ==
(o2)->value.gc->gch.tt),
file ...\lua-5.0.2\src\lfunc.c, line 69

This is triggered by garbage-collecting an unfinished coroutine
containing a function referencing a local in the containing scope.

It's taken me a while to trim my test code down to that below, but now
I'm stuck.  Additionally: if I don't yield it's OK; if t is global it's
OK; and if I don't reference t inside func() it's OK.  If I compile Lua
without assertions, this example survives, but in my real application, I
get access violations later on.

Help!

Martin.


#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"


int main() {

    lua_State* L = lua_open();
    luaopen_base(L);

    lua_dostring(L,
        " coroutine.wrap(function()"
        "  local t={}; "
        "  local func=function() print(type(t)) end; "
        "  func(); "
        "  coroutine.yield()"
        "end)()"
        );

    lua_setgcthreshold(L, 0); // assert happens in here

    return 0;
}