Sign in to follow this  

Lua Crashing Program

This topic is 4728 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having a very strange problem, LUA is crashing my program. Now, that isn't the strange part. The strange part is that the code I am using in another program works without problems, but when added to my engine I get this: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at fputs(SByte* , _iobuf* ) at ?A0x4c700a50.luaB_print(lua_State* L) at luaD_precall(lua_State* L, lua_TObject* func) at luaV_execute(lua_State* L) at luaD_call(lua_State* L, lua_TObject* func, Int32 nResults) at ?A0x4f8a2daa.f_call(lua_State* L, Void* ud) at luaD_rawrunprotected(lua_State* , IntPtr , Void* ) at luaD_pcall(lua_State* L, IntPtr func, Void* u, Int32 oldtop, Int32 ef) at lua_pcall(lua_State* L, Int32 nargs, Int32 nresults, Int32 errfunc) at ?A0x0a637578.aux_do(lua_State* L, Int32 status) at lua_dofile(lua_State* L, SByte* filename) I run everything through a gameManager, and inside that is the luaMgr that handles LUA. So, in main I call gameManager->luaMgr->LuaCreateState(); (which does more then just creating states, I moved everything into it for simplicity and for it to be EXACTLY like my test program. LuaCreateState() contains this:
void CLuaManager::LuaCreateState()
{

lua_State* luaVM = lua_open();
 
   if (NULL == luaVM)
   {
      printf("Error Initializing lua\n");
      return;
   }
    // initialize lua standard library functions

   lua_baselibopen(luaVM);
   lua_iolibopen(luaVM);
   lua_strlibopen(luaVM);
   lua_mathlibopen(luaVM);

   printf("Simple Functional lua interpreter\n");
   printf("Based on lua version 4.0.1\n");
   printf("Enter lua commands. type 'exit<enter>' to exit\n");
   printf("\n>");
 
   lua_dofile(luaVM, "startup.lua");
 
   lua_close(luaVM);
}
Startup.lua contains: -- Simple lua script -- comments indicated with a '--' a = 5; b = 10; c = a + b; print ("5+10=" .. c); I'm definatley including the correct libs, files..I just don't understand the error and why this is happening. If you need any more information don't hesitate to ask. Thank you, Mike

Share this post


Link to post
Share on other sites
Is this a console program? If not, where would it be printing to?

Looking at the stack trace and vaguely remembering my past experiences with lua, I think that may be the problem (the print function). You may have to define your own print function.

It also appears that you are/have compiled lua as Managed code (.NET) rather than unmanaged code. I don't know if that could cause problems, but it certainly is a possibility.

Share this post


Link to post
Share on other sites

This topic is 4728 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this