Skip to content

lua_pushnil invoked with null lua_State in ExecuteLuaFunction #829

Description

@Gopmyc

Description

When the engine calls a Lua function from C++ (ExecuteLuaFunction -> accessing a soltable), the process crashes with an access violation because lua_pushnil is invoked with a null lua_State (L was nullptr). Exception: 0xC0000005 in Dependencies/lua/src/lapi.c (lua_pushnil). The crash originates from solbasic_reference::push calling into Lua while the stored lua_State is null or the Lua context has been destroyed.

To Reproduce

Steps to reproduce the behavior:

  1. Launch OvEditor.exe (use the Overload editor build, preferably in a debugger).
  2. Load a scene that contains an Actor with a Behaviour that has an attached Lua script/context.
  3. Trigger the shutdown/disable lifecycle for that Actor/Behaviour (for example, disable the component or stop play mode so OnDisable is invoked).
  4. Observe the crash in the debugger at Dependencies/lua/src/lapi.c inside lua_pushnil with the message "L was nullptr" when evaluating table[p_functionName].valid().

Expected behavior

Accessing table[p_functionName].valid() or calling ExecuteLuaFunction should not crash. If the Lua context/state is null or the sol::table reference is invalid, the engine should detect this and either skip calling the Lua function and log a warning, or ensure the LuaScript/lua_State lifetime is managed so references remain valid.

Screenshots

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions