sol2
sol2 copied to clipboard
randomly crashing when used in an manually mapped dll
Hey, just found a very weird problem in my project .. if I compile my project as exe and normally start it everything works as expected but when i compile my peoject as dll and manual map it to my target process then its crashing at calling new_usertype
here a snippet how i call it (again no problems in normal executable exe)
`std::cout << "1" << std::endl; Lua = sol::state(); Lua.open_libraries(sol::lib::base, sol::lib::package, sol::lib::math, sol::lib::string, sol::lib::os, sol::lib::table);
std::cout << "2" << std::endl;
//Vector3 To Lua
auto Vector3_Lua = Lua.new_usertype<Vector3>("Vector3",
sol::constructors<Vector3(), Vector3(float, float, float)>(),
"x", &Vector3::x,
"y", &Vector3::y,
"z", &Vector3::z
);
//Vector4 To Lua
auto Vector4_Lua = Lua.new_usertype<Vector4>("Vector4",
sol::constructors<Vector4(), Vector4(float, float, float, float)>(),
"x", &Vector4::x,
"y", &Vector4::y,
"z", &Vector4::z,
"w", &Vector4::w
);
std::cout << "3" << std::endl;`
im printing 1 2 3 since i cant "debug" manually mapped dlls very well and 3 never gets printed out IF ITS CRASHING .. like its crashing 4 out of 5 times and 5th run its working .. very odd
any help would be appreciated :)
edit: ok i got it working past this point somehow .. not sure how but i deleted some of my lua.script() calls after usertypes init so i guess it was crashing there .. so then i did a .load_file() instead and checked the result and printed the error and its saying:
"attempt to load a text chunk (mode "")
i loaded it with sol::load_mode::text tho so it should be mode "1" at leastbut why even throwing this error when the file i pass is a legit/working lua file ? 🤔
again .. in normal compilation as exe its working .. as manual mapped dll in another process its giving me this weird behaviour