lua-users home
lua-l archive

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


** Sorry, the last email got sent accidentally before I finished - Outlook sucks!

This is a bit of a long shot, but I thought some of you Lua gurus might be able to help...

I am using Lua 5.0 beta in a Win32 app (MFC).  I have been using it for months with no troubles.  However, I want to add loadmodule (the 12-18-2002 version from castanyo@yahoo.es) to the project.  After a bit of manipulation to make loadmodule.c to work in my project, I am pretty happy with the results.  I can call module.load("MyModule") and it works great.  I can call lua functions that get added from the DLL as expected.

The problem is that if I call module.load during runtime, I will always get an access violation when my application exits.  The access violation occurs here (ltable.c):

/*
** search function for strings
*/
const TObject *luaH_getstr (Table *t, TString *key) {
  Node *n = hashstr(t, key);
  do {  /* check whether `key' is somewhere in the chain */
>>>> THIS LINE >>>>    if (ttisstring(key(n)) && tsvalue(key(n)) == key)
      return val(n);  /* that's it */
    else n = n->next;
  } while (n);
  return &luaO_nilobject;
}

Here is the call stack:

luaH_getstr(Table * 0x015e9530, TString * 0x015d2570) line 432 + 3 bytes
luaT_gettm(Table * 0x015e9530, int 2, TString * 0x015d2570) line 49 + 13 bytes
separateudata(lua_State * 0x015d1510) line 123 + 56 bytes
luaC_callallgcTM(lua_State * 0x015d1510) line 433 + 9 bytes
lua_close(lua_State * 0x015d1510) line 201 + 9 bytes

Anyhow, I am at a loss probably due to my general ignorance about the inner workings of Lua.  If anyone has any ideas at all I would love to hear them.  Thanks for your help in advance!

- Brett Kapilik
- brett@indigorose.com