0

I have made a C module for lua as a dll that I load in Lua using the package.loadlib function. The module is supposed to use luaL_loadstring to execute some lua code from a string. My lua script is run by an application I didn't code myself, and my module is supposed to extend the functionality of the application. When using luaL_loadstring and lua_pcall on the result the application crashes on some strings, especially those using functions that call some C functions defined by the application (Note that it doesn't crash on all of the C defined functions, just some of them). It works fine on the strings it doesn't crash on, and on those that it does crash on I can use push the result from loadstring back to lua and execute it just fine there, showing that the code itself should be valid.

This is how I call it:

lua_getglobal(L, "loadstring");
lua_pushstring(L, msg);
lua_call(L, 1, 1);
lua_call(L, 0, 0);

Are there any suggestions for what might cause these crashes?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Dennefyren
  • 344
  • 1
  • 2
  • 8
  • 2
    Compile Lua with assertions enabled (define `LUA_USE_APICHECK`) and try running it again. – Colonel Thirty Two Jul 26 '14 at 18:49
  • It didn't change anything sadly. I still get crashes. – Dennefyren Jul 28 '14 at 18:12
  • Run it in a debugger and see where it crashes. We can't do anything without more info. – Colonel Thirty Two Jul 28 '14 at 18:30
  • The application has anti debugger measurements and the script+module runs fine through my own lua.exe. I am guessing there is some way the application deals with some lua calls that makes it crash. But I understand that it would be hard to diagnose without more info, but thank you for the effort anyway. I might try contacting the developer. – Dennefyren Jul 28 '14 at 18:39
  • Provide the assertion error messages – Demi Sep 13 '15 at 18:53

0 Answers0