actboy168 / lua-debug

Lua Debug Adapter for Visual Studio Code
MIT License
439 stars 95 forks source link

luaArch设定为x86时,经常无法正常启动debugger #270

Open rascalrr opened 1 year ago

rascalrr commented 1 year ago
{
    "luaVersion": "5.4",
    "luaArch": "x86_64",
    "type": "lua",
    "request": "launch",
    "name": "Debug",
    "program": "${workspaceFolder}/test.lua",
    "stopOnEntry": false
}

代码只是简单的输出1,2,3。在普通的luaVersion 和 luaArch下的测试结果。

PS D:\test\lua\test>  d:; cd 'd:\test\lua\test'; & 'c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-x64/lua51/lua.exe' '-e' 'dofile[[c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/script/launch.lua]];DBG[[22680-ansi]]' 'D:\test\lua\test/test.lua' 
1
2
3
PS D:\test\lua\test>  d:; cd 'd:\test\lua\test'; & 'c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-x64/lua51/lua.exe' '-e' 'dofile[[c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/script/launch.lua]];DBG[[4948-ansi]]' 'D:\test\lua\test/test.lua' 
1
2
3
PS D:\test\lua\test>  d:; cd 'd:\test\lua\test'; & 'c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-ia32/lua51/lua.exe' '-e' 'dofile[[c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/script/launch.lua]];DBG[[21304-ansi]]' 'D:\test\lua\test/test.lua'
PS D:\test\lua\test>  d:; cd 'd:\test\lua\test'; & 'c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-ia32/lua51/lua.exe' '-e' 'dofile[[c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/script/launch.lua]];DBG[[14184-ansi]]' 'D:\test\lua\test/test.lua'
PS D:\test\lua\test>  d:; cd 'd:\test\lua\test'; & 'c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-ia32/lua54/lua.exe' '-e' 'dofile[[c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/script/launch.lua]];DBG[[21584-ansi]]' 'D:\test\lua\test/test.lua'
PS D:\test\lua\test>  d:; cd 'd:\test\lua\test'; & 'c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-x64/lua54/lua.exe' '-e' 'dofile[[c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/script/launch.lua]];DBG[[13980-ansi]]' 'D:\test\lua\test/test.lua'
1
2
3
PS D:\test\lua\test>

luaArch 设置为x86的时候,经常无法启动debugger (有很小的几率成功),设置为x86_64的时候都正常。 也试过lua5.1 和 lua5.4 也是一样的现象。 另外,6月份的时候没注意到这个问题,今天新建一个project才发现的。

sumneko commented 1 year ago

你是不是把 console 设置成 internalConsole 了?

rascalrr commented 1 year ago

你是不是把 console 设置成 internalConsole 了?

并没有,默认的"integratedTerminal"。 luaArch 设置为x86时,以下三种设置我也试了一遍: integratedTerminal :debugger启动几秒后自动关闭 internalConsole:无反应,有极小概率在调试控制台输出结果。 externalTerminal:弹出cmd窗口显示“按任意键继续”无其他输出

luaArch 设置为 x86_64 时,上述三种Console模式输出都正常。

actboy168 commented 1 year ago

我不能重现

rascalrr commented 1 year ago

我不能重现

换了台电脑试了下,也不能复现。哎~

rascalrr commented 1 year ago

@actboy168 无意中发现windows日志中有记录。摘抄如下:

错误应用程序名称: lua.exe,版本: 0.0.0.0,时间戳: 0x63bccec3
错误模块名称: unknown,版本: 0.0.0.0,时间戳: 0x00000000
异常代码: 0xc0000005
错误偏移量: 0x5d1fb6d4
错误进程 ID: 0x4efc
错误应用程序启动时间: 0x01d9dae9a635de1b
错误应用程序路径: C:\Users\Foxy\.vscode\extensions\actboy168.lua-debug-1.61.0-win32-x64\runtime\win32-ia32\lua51\lua.exe
错误模块路径: unknown
报告 ID: e75fd4b1-c20c-4d8d-b306-1d885e9c2fd0
错误程序包全名: 
错误程序包相对应用程序 ID: 
故障存储段 1819918778263019964,类型 5
事件名称: BEX
响应: 不可用
Cab ID: 0

问题签名:
P1: lua.exe
P2: 0.0.0.0
P3: 63bccec3
P4: StackHash_4c4a
P5: 0.0.0.0
P6: 00000000
P7: PCH_11_FROM_ntdll+0x0007300C
P8: c0000409
P9: 00000015
P10: 

附加文件:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER3C12.tmp.mdmp
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER3CFD.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER3D1E.tmp.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER3D33.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER3D63.tmp.txt
\\?\C:\Users\Foxy\AppData\Local\Temp\WER3D6E.tmp.appcompat.txt
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_lua.exe_dbdc8f9dd89c7856351df79af997c134ad3deb_b6af5666_cab_679a866e-0097-42b4-9b89-4005d2541c5f\memory.hdmp

可在此处获取这些文件:
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_lua.exe_dbdc8f9dd89c7856351df79af997c134ad3deb_b6af5666_679a866e-0097-42b4-9b89-4005d2541c5f

分析符号: 
重新检查解决方案: 0
报告 ID: 9d8184f2-1ffc-44af-9439-9c6621a50f08
报告状态: 268435456
哈希存储段: e8fb9af171b60819e941a67c8a6e21bcnCab GUID: 0
故障存储段 1278807887927070580,类型 5
事件名称: BEX
响应: 不可用
Cab ID: 0

问题签名:
P1: lua.exe
P2: 0.0.0.0
P3: 63bccec3
P4: StackHash_b4ee
P5: 0.0.0.0
P6: 00000000
P7: PCH_03_FROM_unknown+0x00000000
P8: c0000005
P9: 00000008
P10: 

附加文件:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER40B6.tmp.mdmp
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER41A1.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER41C1.tmp.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER41D9.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER4209.tmp.txt

可在此处获取这些文件:
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_lua.exe_2e5f8b2643236626065dab5f89a53cb7a7db_b6af5666_dbca6d93-5250-4016-8235-255ad34d3e96

分析符号: 
重新检查解决方案: 0
报告 ID: e75fd4b1-c20c-4d8d-b306-1d885e9c2fd0
报告状态: 268435456
哈希存储段: 80dc57825366722741bf3cffa7dc4f74nCab GUID: 0
rascalrr commented 1 year ago

关闭DEP数据执行保护后,可以看到错误模块:

错误模块名称: COMCTL32.dll,版本: 6.10.19041.1110,时间戳: 0x101d7274
错误模块路径: C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_a8625c1886757984\COMCTL32.dll
rascalrr commented 1 year ago

为了便于观察,我尝试在lua debug的一些关键点上打了一些日志。 '=>'左侧大写的是lua debug 的script脚本名称,'=>' 右侧是方法名及一些参数

这是x64下正常运行的日志

DEBUGGER => remotedebug:c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-x64/lua51/remotedebug.dll
MGR => mgr.init
WORKER => sendToMaster:initWorker
WORKER => debuggeeReady
MGR => update_once cmd:initWorker
THREADS => CMD.initWorker
MGR => mgr.initWorker WorkerIdent:0 threadId:1
EVENT => initialized
EVENT => capabilities
REQUEST => request.configurationDone
REQUEST => initializeWorker begin
REQUEST => initializeWorker end
WORKER => CMD.setSearchPath
WORKER => sendToMaster:eventThread
MGR => update_once cmd:eventThread
THREADS => CMD.eventThread
EVENT => thread
1
2
WORKER => sendToMaster:exitWorker
MGR => update_once cmd:exitWorker
MGR => update_once cmd:EXIT
MGR => mgr.update end

这是 x86 模式下,中断的日志

DEBUGGER => remotedebug:c:/Users/Foxy/.vscode/extensions/actboy168.lua-debug-1.61.0-win32-x64/runtime/win32-ia32/lua51/remotedebug.dll
WORKER => sendToMaster:initWorker
WORKER => debuggeeReady
MGR => mgr.init
MGR => update_once cmd:initWorker
THREADS => CMD.initWorker
MGR => mgr.initWorker WorkerIdent:0 threadId:1

可以发现x86模式下未收到EVENT => initialized 这个消息。我的理解是此处因由 remotedebug 返回一个初始化成功的消息。不知道我的理解对不对? 因为没有remotedebug的源码,也只能调查到这一步。

还请@actboy168抽空看一下,谢谢~

rascalrr commented 1 month ago

尝试了下 2.0.10版,现象还在,x86下一次都没启动成功。 退回 2.0.3版,都正常了。

actboy168 commented 1 month ago

因为没有remotedebug的源码,也只能调查到这一步。

所有的代码都在这个repo里啊