Giter Club home page Giter Club logo

Comments (9)

stuartwang avatar stuartwang commented on May 21, 2024 1

我今天看了下,上面方案是不行的。从类型来说 UE4.FVector 是 function , 而 UE4.FVector() 是返回值的类型。一些成员类型的变量也不能直接加() ,比如 UE4.UKismetSystemLibrary 。

因为crash 都发生在 UE4 提供的一些方法中,我可以做一些工作,让用户主动查阅需要的变量,避免不经意查询了 UE4 的提供方法。
从我自己的测试状况,造成 crash 的行为主要是

  • 鼠标不小心悬停在了会 crash 的方法上(会进行变量查询,然后 crash)
  • 查询所有 global 变量(因为其中包含 UE4.FVector 等 userdata)
    所以我准备:
  • 禁止鼠标悬停查询变量
  • 停止在变量展示区 展示全部 global 变量
    这样查询全局变量会稍麻烦一点,需要使用 watch 或调试控制台输入变量名查询,如下
    image

但只要用户不主动查询 UE4 提供的方法,应该都是安全的

from luapanda.

stuartwang avatar stuartwang commented on May 21, 2024

我们定位了一下问题,crash发生在LuaPanda.lua processWatchedExp函数2575行

var.value = tostring(retString)

这行的作用是把观察变量取得的变量值,转换为string。之后序列化发给前台以便展示。
也就是一些系统变量在做tostring转化时,出现了问题。

必现办法是:比如在watch中加入UE4.FVector,调试器就会立刻crash掉。
或者在用户lua代码中加入 tostring(UE4.FVector); 运行工程,ue也会crash.

问题可能的原因是unlua目前对一些变量的tostring没有处理好,我们后面看下有没有办法绕过

from luapanda.

hxhb avatar hxhb commented on May 21, 2024

我们定位了一下问题,crash发生在LuaPanda.lua processWatchedExp函数2575行

var.value = tostring(retString)

这行的作用是把观察变量取得的变量值,转换为string。之后序列化发给前台以便展示。
也就是一些系统变量在做tostring转化时,出现了问题。

必现办法是:比如在watch中加入UE4.FVector,调试器就会立刻crash掉。
或者在用户lua代码中加入 tostring(UE4.FVector); 运行工程,ue也会crash.

问题可能的原因是unlua目前对一些变量的tostring没有处理好,我们后面看下有没有办法绕过

请问现在有解决的办法吗?

from luapanda.

stuartwang avatar stuartwang commented on May 21, 2024

请问现在有解决的办法吗?

想先说下调试器对变量进行 tostring() 的原因:
调试器有 lua 端和 vscode 插件两部分,他们之间通过tcp通信。遇到断点时,调试器 lua 端把获得的变量信息序列化后发给 VSCode 端,VSCode插件把这些信息反序列化后展示。我们这里调用 tostring 的目的就是对获得的变量进行序列化,以便传输。

所以我认为这里有两种可能,一种是 unlua 修复变量的 tostring() 方法。另一种是 unlua 提供他们自己的的变量序列化方法,我们做一下适配也可以解决。

就这个问题我理解比较依赖 unlua 的处理,核心是找到一个不 crash 的变量序列化方法。

感谢提问,我们也会关注这个问题~

from luapanda.

hxhb avatar hxhb commented on May 21, 2024

请问现在有解决的办法吗?

想先说下调试器对变量进行 tostring() 的原因:
调试器有 lua 端和 vscode 插件两部分,他们之间通过tcp通信。遇到断点时,调试器 lua 端把获得的变量信息序列化后发给 VSCode 端,VSCode插件把这些信息反序列化后展示。我们这里调用 tostring 的目的就是对获得的变量进行序列化,以便传输。

所以我认为这里有两种可能,一种是 unlua 修复变量的 tostring() 方法。另一种是 unlua 提供他们自己的的变量序列化方法,我们做一下适配也可以解决。

就这个问题我理解比较依赖 unlua 的处理,核心是找到一个不 crash 的变量序列化方法。

感谢提问,我们也会关注这个问题~

我测试了一下,这是因为UE.FVector这个用法不会走FVector的构造,导致调用tostring的时候传递进去的是一个空指针。而UE4.FVector()就可以。

这样是OK的:

function Cube_Blueprint_C:ReceiveBeginPlay()
    print(tostring(UE4.FVector()))
end

这样就不会调用FVector_New,从而在调用tostring的时候会crash:

function Cube_Blueprint_C:ReceiveBeginPlay()
    print(tostring(UE4.FVector))
end

from luapanda.

stuartwang avatar stuartwang commented on May 21, 2024

收到。根据上面结果,我的初步想法是:在调试器获取到要展示的变量后,通过某些方式(按变量名或者type()等)判断它是 lua 基本类型还是 unlua 的 UE4.xxx 类型,如果是基础类型,就直接用tostring()序列化。如果是UE4.xxx, 那么调用它一下再使用tostring。

from luapanda.

stuartwang avatar stuartwang commented on May 21, 2024

我在 master 分支提交了一个 vsix 文件夹,按上面的思路打了个包,可以安装上试下。
image
下载到 vsix 文件后,可以按下面的办法安装
image

from luapanda.

hxhb avatar hxhb commented on May 21, 2024

我在 master 分支提交了一个 vsix 文件夹,按上面的思路打了个包,可以安装上试下。
image
下载到 vsix 文件后,可以按下面的办法安装
image

好的,我试一下~

from luapanda.

stuartwang avatar stuartwang commented on May 21, 2024

unlua 的更新似乎解决了这个bug, 参见下方相关issue

from luapanda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.