Skip to content

启动 LuaPanda 的时候出现错误 #395

@GotGimhong

Description

@GotGimhong

我们引入了 LuaPanda 来调试 Lua,然后发现启动 LuaPanda 的时候,会在 Lua 的源代码当中出现错误,导致游戏崩溃。

我们定位到出错的源头是 LuaPanda.lua 当中执行了 require("socket.core"),也就是加载 core.dll 的时候出现了错误。我们还发现这个问题是从 2.0.0 版本开始出现的,所以也许是 Lua 5.4 不兼容 LuaPanda?

测试方法如下:

  1. 下载 LuaPanda.luacore.dll ,然后按照以下目录结构放到 Script 目录下:
    • Script/
      • LuaPanda/
        • LuaPanda.lua
        • socket/
          • core.dll
  2. 修改 BP_Game_C.lua,在 BP_Game_C:ReceiveBeginPlay 函数中,添加以下代码:
    local newSearchPath = UE.UBlueprintPathsLibrary.ProjectContentDir() .. "Script/LuaPanda/?.dll"
    package.cpath = package.cpath .. ";" .. newSearchPath
    
    -- 测试的时候,加载 core.dll 就能触发错误,不需要真正启动 LuaPanda
    local socketCore = require("socket.core")
  3. 运行游戏的时候就能复现错误了

以下是堆栈信息:

  1. luaD_precall,ldo.c 第503行
  2. ccall,ldo.c 第546行
  3. luaD_callnoyield,ldo.c 第566行
  4. lua_callk,lapi.c 第987行
  5. ll_require,loadlib.c 第668行

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions