lua-users home
lua-l archive

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


2013/4/21 Dirk Laurie <dirk.laurie@gmail.com>:
> Sorry, hit the sent button too soon. The behaviour of the
> title occurs in a long module of mine, and I am still trying
> to isolate it. It's not that simple. Sorry!

Turns out I have been too clever for my own good.

My module loads another module written in C. That module has a tiny bit
of initialization code in Lua. I use a global variable also called
'X' in there; I delete it immediately, but the bug detector picks it up.
The C file ends something like this:

~~~
char *mymodule_init =
"for k,v in pairs(_G) do X[k]=v end "
"X=nil"
;

LUAMOD_API int luaopen_mymodule_core (lua_State *L) {
  luaL_newlib(L, myfuncs);
  lua_pushvalue(L,-1); lua_setglobal(L,"X");
  (void)luaL_dostring(L,mymodule_init);
  return 1;
}
~~~

Actually, I have not been clever at all. Global variables with one-letter
names are hazardous even in initializion code in a C module, The bug
detector in my original accidental post does exactly what it should.