[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Unitialized Lua Stae using 5.1 causes abort
- From: "Edward Mitchell" <emitchell@...>
- Date: Sun, 24 Sep 2006 11:40:39 -0400
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();
luaopen_base(pLuaState);
luaopen_io(pLuaState);
...
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) {
createmeta(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:
case LUA_ENVIRONINDEX: {
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
initialized.
How can I initialize the program properly?
Ed
--
Edward E.L. Mitchell
Phone: (508)771-0806
500 Ocean St., Unit 134,
Hyannis, MA 02601