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
sol2 3.3.1
vs2022 17.11.1
build with c++ 20 in x86 release mode crash(debug mode is ok...)
c++ code:
`
try{
//ver1:call module function
sol::table self = g_LuaState["abcmod"];//crash here
sol::table rv = self["getResult"](1, 2, 3);
//ver2:call global function
sol::table rv = g_LuaState["getResult"](1, 2, 3);//sometimes will throw exception:stack index 1, expected string, received no value: bad get from protected_function_result (is not an error)
}
catch (const sol::error& err)//can not catch crash with module call
{
ShowLuaException(err);
}
`
ver1:lua module code:
`
abcmod={};
local this=abcmod;
function doFunc1(a, b, c)
return {[1]=2};
end
function doFunc2(a, b, c)
return {[2]=3};
end
function this.getResult(a, b, c)
local mapFuncs={
[1]=doFunc1,
[2]=doFunc2,
};
local func = mapFuncs[cid];
local retMap={};
if (func == nil) then
return retMap;
end
return func(a, b, c);
end
return this; ver2:lua global function code:
function doFunc1(a, b, c)
return {[1]=2};
end
function doFunc2(a, b, c)
return {[2]=3};
end
function getResult(a, b, c)
local mapFuncs={
[1]=doFunc1,
[2]=doFunc2,
};
local func = mapFuncs[cid];
local retMap={};
if (func == nil) then
return retMap;
end
return func(a, b, c);
end
`
The text was updated successfully, but these errors were encountered:
warsark
changed the title
C++ call lua module func will crash!
C++ call lua module func will crash in release mode!
Aug 24, 2024
@warsark Please format your code correctly using markdown for further reference, because in its current form it is unlikely that someone will look into it.
sol2 3.3.1
vs2022 17.11.1
build with c++ 20 in x86 release mode crash(debug mode is ok...)
c++ code:
`
try{
//ver1:call module function
sol::table self = g_LuaState["abcmod"];//crash here
//ver2:call global function
sol::table rv = g_LuaState["getResult"](1, 2, 3);//sometimes will throw exception:stack index 1, expected string, received no value: bad get from protected_function_result (is not an error)
`
ver1:lua module code:
`
abcmod={};
local this=abcmod;
function doFunc1(a, b, c)
return {[1]=2};
end
function doFunc2(a, b, c)
return {[2]=3};
end
function this.getResult(a, b, c)
local mapFuncs={
[1]=doFunc1,
[2]=doFunc2,
};
local func = mapFuncs[cid];
local retMap={};
if (func == nil) then
return retMap;
end
return this;
ver2:lua global function code:
function doFunc1(a, b, c)
return {[1]=2};
end
function doFunc2(a, b, c)
return {[2]=3};
end
function getResult(a, b, c)
local mapFuncs={
[1]=doFunc1,
[2]=doFunc2,
};
local func = mapFuncs[cid];
local retMap={};
if (func == nil) then
return retMap;
end
`
The text was updated successfully, but these errors were encountered: