Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sol2 兼容BUG #181

Open
tyler-chang opened this issue Mar 22, 2024 · 2 comments
Open

sol2 兼容BUG #181

tyler-chang opened this issue Mar 22, 2024 · 2 comments

Comments

@tyler-chang
Copy link

我们项目中使用 sol2 3.2.3 作为绑定库.
在不使用 sol2 注册任何类型时. 调试一切正常.
当使用sol2注册一个类型: 如下代码:
m_lua.new_usertype<CLogger>("CLogger", "debug_print", &CLogger::DebugPrint);
再进行调试时, 调试器就会崩溃. 提示以下错误:

CScript: sol: runtime error: sol: cannot call '__pairs/pairs' on type 'sol::as_container_t<CLogger>': it is not recognized as a container
stack traceback:
	[C]: in ?
	[C]: in function 'pairs'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:754: in function 'LuaPanda.getTableMemberNum'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:2768: in function 'LuaPanda.getGlobalVariable'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1238: in function 'LuaPanda.dataProcess'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1559: in function 'LuaPanda.receiveMessage'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1602: in function 'LuaPanda.debugger_wait_msg'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1255: in function 'LuaPanda.dataProcess'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1559: in function 'LuaPanda.receiveMessage'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1602: in function 'LuaPanda.debugger_wait_msg'
	...
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1602: in function 'LuaPanda.debugger_wait_msg'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1151: in function 'LuaPanda.dataProcess'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1559: in function 'LuaPanda.receiveMessage'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1602: in function 'LuaPanda.debugger_wait_msg'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1151: in function 'LuaPanda.dataProcess'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1559: in function 'LuaPanda.receiveMessage'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:1602: in function 'LuaPanda.debugger_wait_msg'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:2282: in function 'LuaPanda.SendMsgWithStack'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:2216: in function 'LuaPanda.real_hook_process'
	D:\WorkSpace\April\Release\..\Public\Script\LuaPanda.lua:2073: in function 'LuaPanda.debug_hook'
	D:\WorkSpace\April\Release\..\Public\Script\launcher.lua:71: in main chunk 
Exception thrown at 0x0103CF5A in Gaze.exe: 0xC0000005: Access violation reading location 0x0000001C.

注: 崩溃不会立即发生. 在点击调试器 Global 时崩溃(如下图)
image

@stuartwang
Copy link
Collaborator

我看到是 getGlobalVariable 在序列化全局变量时出错了。原因是导入的CLogger类型无法用pairs遍历。导致遍历时出错

image

这里的修复需要有接口能够判断是so2导入类型,并对导入类型进行序列化,也可以简单点处理对导入类型不做遍历操作。这个库我之前没用过,有空的时候我看一下

@tyler-chang
Copy link
Author

好的, 谢谢.
sol2 绑定库用的人还是蛮多的. 可以适当兼容一下.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants