lua-users home
lua-l archive

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

I am trying to get a test program to work using Lua 5.1.  The initialization
sequence in the main console program is:

void main(void)
   lua_State *pLuaState = lua_open();
and my program dies in luaopen_io(...).  I am using VS.NET 2003 to build the
library (LuaLib.lib) and run this test program.

Inside luaopen_io(..) is:

LUALIB_API int luaopen_io (lua_State *L) {
   /* create (private) environment (with fields IO_INPUT, IO_OUTPUT,
__close) */
   lua_createtable(L, 2, 1);
   lua_replace(L, LUA_ENVIRONINDEX);
The lua_replace() leads to o=index2adr(L, idx) with the idx value -1001.

The problem is caused here:

     Closure *func = curr_func(L);
     sethvalue(L, &L->env, func->c.env);

where the curr_func() returns 0xcdcdcdcd which is Microsoft speak for
uninitialised memory and the program dies at the line following.

The curr_func() is a macro defined by:

#define curr_func(L) (clvalue(L->ci->func))

The lua_State has a valid pointer for the ci->func.  The problem seems to
originate in the access to the value (via clvalue() macro) which is

How can I initialize the program properly?

Edward E.L. Mitchell
Phone: (508)771-0806
500 Ocean St., Unit 134,
Hyannis, MA 02601