lua-users home
lua-l archive

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


Hi,
I have found a possible bug in tolua++. When I'm using the addon lua script for creating virtual calls, it failed with the message below. It does work with 5.1.4 version but when I did add the latest patch, it does crash. And as far I can see it is one line in llex.c that is the problem. An extra line that calls the gc, also below. Perhaps the gc deletes the script?

Lua script for virtual calls: http://lua-users.org/files/wiki_insecure/users/ArielManzur/tolua++/virtual_method_hooks.lua

Patch for lua:
http://www.lua.org/ftp/patch-lua-5.1.4-2

I tried to mail tolua@codenix.com but it failed.


***curr code for error is const _cstring      value(void);

stack traceback:
[string "tolua embedded: src/bin/lua/basic.lua"]:91: in function 'tolua_error'
      [string "tolua: embedded Lua code 23"]:5: in main chunk

** tolua internal error: [string "tolua embedded: src/bin/lua/function.lua"]:316: attempt to call global 'output_error_hook' (a nil value).


stack traceback:
      [string "tolua: embedded Lua code 23"]:6: in main chunk




--- llex.c    2007/12/27 13:02:25    2.20.1.1
+++ llex.c    2009/11/23 14:58:22    2.20.1.2
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
+** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -118,8 +118,10 @@
 lua_State *L = ls->L;
 TString *ts = luaS_newlstr(L, str, l);
 TValue *o = luaH_setstr(L, ls->fs->h, ts);  /* entry for `str' */
-  if (ttisnil(o))
+  if (ttisnil(o)) {
   setbvalue(o, 1);  /* make sure `str' will not be collected */
+    luaC_checkGC(L);
+  }
 return ts;


}

/Foobar