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?