You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static int userd(lua_State* State){
auto obj=lua_newuserdata(State,10);
return 1;
}
int _tmain(int argc, char* argv[]){
LuaState=luaL_newstate();
luaL_openlibs(LuaState);
lua_pushcfunction(LuaState,userd);
lua_setglobal(LuaState,"userd");
auto buf=R"(
local Array={}
Array.push_back=function(a,val)
table.insert(a,val)
end
local e={}
while true do
Array.push_back(e,1) //it works correct, return "not enough memory" information
end
)";
luaL_loadstring(LuaState,buf);
lua_pcall(LuaState,0,0,1);
lua_close(LuaState);
return 0;
}
static int userd(lua_State* State){
auto obj=lua_newuserdata(State,10);
return 1;
}
int _tmain(int argc, char* argv[]){
LuaState=luaL_newstate();
luaL_openlibs(LuaState);
lua_pushcfunction(LuaState,userd);
lua_setglobal(LuaState,"userd");
auto buf=R"(
local Array={}
Array.push_back=function(a,val)
table.insert(a,val)
end
local e={}
while true do
Array.push_back(e,userd()) //cause a exception
end
)";
luaL_loadstring(LuaState,buf);
lua_pcall(LuaState,0,0,1);
lua_close(LuaState);
return 0;
}
static int userd(lua_State* State){
auto obj=lua_newuserdata(State,10);
return 1;
}
int _tmain(int argc, char* argv[]){
LuaState=luaL_newstate();
luaL_openlibs(LuaState);
lua_pushcfunction(LuaState,userd);
lua_setglobal(LuaState,"userd");
auto buf=R"(
local Array={}
Array.push_back=function(a,val)
table.insert(a,val)
end
local e={}
while true do
--Array.push_back(e,userd())
table.insert(e,userd()) //it works correct, return "not enough memory" information
end
)";
luaL_loadstring(LuaState,buf);
lua_pcall(LuaState,0,0,1);
lua_close(LuaState);
return 0;
}
The text was updated successfully, but these errors were encountered:
Always use the latest v2.1 git version before reporting issues. Also read the section on Exception Interoperability in the v2.1 documentation and what this means for Windows compilation settings.
Always use the latest v2.1 git version before reporting issues. Also read the section on Exception Interoperability in the v2.1 documentation and what this means for Windows compilation settings.
Thank you for taking the time to reply.
We are using the latest version of Luajit 2.1 in 32-bit mode.
We did follow-up tests and came to the following conclusions:
All versions of luajit 2.1, enable jit and call c function, when the memory is exhausted, a memory conflict will be triggered, and close jit is normal.
Luajit version 2.0.5 has the same test conditions, and it can run normally regardless of whether JIT is enabled or not.
Looking forward to your help, thank you very much!
Thank you for your excellent work, luajit is an excellent tool.
So,we wrote a script interpreter based on luajit, and it is possible for our users to write out of memory scripts.
Therefore, we want to prompt memory exhaustion, but our test code will cause memory access errors.
The test code is the simplest example that has been put together after repeated verification.
The test code is as follows:
This code works correct,the vm will return "not enough memory" as follow picture:
Array.push_back function return not enough memory information
This code causes a exception as follow picture:
Array.push_back function cause exception information
This code works correct,the vm will return "not enough memory" as follow picture:
table.insert function return not enough memory information
The text was updated successfully, but these errors were encountered: