luaplus51-all icon indicating copy to clipboard operation
luaplus51-all copied to clipboard

pointer to invalid LuaState in LuaObject

Open IntendedConsequence opened this issue 7 years ago • 0 comments

In LuaObject's contructors and assignment operators, if src LuaObject happens to come from a coroutine then this LuaObject LuaState L will point to freed memory once the coroutine is garbage collected. Which results in all kinds of nasty business, especially in production code :( From reading the reference, it appears that using lua_pushthread's return value of 1 for a non-coroutine lua_State should help identify that case and lua_xmove should transfer the object for a proper fastref in this's LuaObject's LuaState. https://github.com/jjensen/luaplus51-all/blob/7eb904cbbbd8a5ba376a389538cee5455c394959/Src/LuaPlus/LuaObject.inl#L76-L89

IntendedConsequence avatar Jun 06 '18 20:06 IntendedConsequence