lldb-mi freezes on MacOS when breaking near uninitialised variables
还没有人认领这个 Issue。
评估
调研方向
先从最小复现用例的 main.cpp、launch.json 和 tasks.json 开始,然后运行 MacOS lldb-mi 会话,并检查 bad_var 的 scopes 和 var-create 附近的引擎日志。将其行为与命令行 lldb 以及链接的复现用例进行比较。当步入 freeze_up 不再使 lldb-mi 消耗过多 CPU 或内存,并且 VS Code 不再停留在等待局部变量时冻结,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Type: Debugger
Describe the bug
- OS and Version: MacOS 11.2.3 (Big Sur)
- VS Code Version: 1.5.4.3
- C/C++ Extension Version: 1.2.2
- I have recreated on both Intel and Apple Silicon (Rosetta) MacBook Pros.
During debugging, if stopping on (or stepping in to) a frame containing certain types of uninitialised variables, lldb-mi gets stuck at 100% cpu and starts to consume multiple GBs of memory.
I've encountered this a a few times in different code, I've condensed the latest example in to a tiny snippet (below), using a std::initialiser_list<int>.
I couldn't reproduce using the lldb command line. Xcode is fine too, but I notice it uses lldb-rpc-server to communicate with debugserver instead of lldb-mi.
I also tried using the CodeLLDB extension (https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) which doesn't suffer with the same problem (and doesn't use lldb-mi) - but interestingly, it does try to inspect the values of the initializer_list but times out after a short time.
If debugging is stopped while this is going on, the lldb-mi process continue to spin with high cpu usage in the background.
This may be related to the following:
- https://github.com/microsoft/vscode-cpptools/issues/5805
- https://github.com/microsoft/vscode-cpptools/issues/860
- https://github.com/microsoft/vscode-cpptools/issues/1899
The issue may not be directly related to cpptools (could be an lldb-mi bug?), but the extension suffers as a result - in that case, maybe there is something between the interaction with lldb-mi and cpptools that could avoid triggering the bug.
To Reproduce
(I've also prepared a tiny repo for easily reproducing the problem here: https://github.com/andrewfindon/lldbmi-freeze)
To trigger the problem, step in to the freeze_up() function in the example below. The lldb-mi process should spike in cpu/memory usage and vscode will appear to freeze waiting for local variables to resolve.
main.cpp
#include <initializer_list>
void freeze_up()
{
auto bad_var = {1, 2, 3}; // A breakpoint here will trigger the issue.
} // A breakpoint here is fine (bad_var is initialised).
int main() {
freeze_up();
return 0;
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/freeze",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "clang++ build",
"logging": {
"engineLogging": true,
"trace": true,
"traceResponse": true
}
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang++ build",
"command": "/usr/bin/clang++",
"args": [
"main.cpp",
"-arch",
"x86_64",
"-std=c++17",
"-Wall",
"-g",
"-o",
"freeze",
],
"problemMatcher": [
"$gcc"
],
"group": "build",
}
]
}
The tail of my engine logging output at the point where the debugger has frozen on a breakpoint, looks like:
--> E (stopped): {"type":"event","event":"stopped","body":{"reason":"step","threadId":1,"allThreadsStopped":true,"source":{"name":"main.cpp","path":"/Users/andrewfindon/Documents/lldbmi-crash/main.cpp","sources":[],"checksums":[]},"line":6,"column":1},"seq":641}
<-- C (threads-12): {"command":"threads","type":"request","seq":12}
--> R (threads-12): {"type":"response","request_seq":12,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"Thread #1"}]},"seq":644}
<-- C (stackTrace-13): {"command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":20},"type":"request","seq":13}
--> R (stackTrace-13): {"type":"response","request_seq":13,"success":true,"command":"stackTrace","body":{"stackFrames":[{"id":1000,"name":"freeze!freeze_up()","source":{"name":"main.cpp","path":"/Users/andrewfindon/Documents/lldbmi-crash/main.cpp","sources":[],"checksums":[]},"line":6,"column":1,"moduleId":1},{"id":1001,"name":"freeze!main","source":{"name":"main.cpp","path":"/Users/andrewfindon/Documents/lldbmi-crash/main.cpp","sources":[],"checksums":[]},"line":12,"column":1,"moduleId":1},{"id":1002,"name":"libdyld.dylib!start","line":0,"column":0,"moduleId":12},{"id":1003,"name":"libdyld.dylib!start","line":0,"column":0,"moduleId":12}],"totalFrames":4},"seq":647}
<-- C (scopes-14): {"command":"scopes","arguments":{"frameId":1000},"type":"request","seq":14}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (33618) <-1018-stack-list-variables 0 --thread 1 --frame 0\n"},"seq":650}
1: (33618) <-1018-stack-list-variables 0 --thread 1 --frame 0
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (33631) ->1018^done,variables=[{name=\"bad_var\"}]\n"},"seq":652}
1: (33631) ->1018^done,variables=[{name="bad_var"}]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (33631) ->(gdb)\n"},"seq":654}
1: (33631) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (33632) 1018: elapsed time 13\n"},"seq":656}
1: (33632) 1018: elapsed time 13
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (33657) <-1019-var-create - - \"bad_var\" --thread 1 --frame 0\n"},"seq":658}
1: (33657) <-1019-var-create - - "bad_var" --thread 1 --frame 0
Here's a trace of lldb-mi in Instruments - it's clear on the timeline when I stepped in to the freeze_up function:

Example debugging session:
- 主要语言
- TypeScript
- 星标
- 6.2k
- 派生
- 1.7k
- 平均合并
- 14 小时 46 分钟
- 30 天内合并 PR
- 61
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/vscode-cpptools 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
microsoft/vscode-cpptools#14787 ·
-
[Bug] cpptools fails to start on Ubuntu ARM64 due to missing execute permissions on shared libraries 未关闭bug fixed Language Service regression
microsoft/vscode-cpptools#14779 · 已指派 1 人 ·
-
Language Service more info needed
microsoft/vscode-cpptools#14778 · 1 条评论 · 已指派 1 人 ·
-
难度 4/5 3-5 天 新手友好度 64/100
microsoft/vscode-cpptools#14769 ·
-
难度 3/5 1-2 天 新手友好度 68/100
microsoft/vscode-cpptools#14768 · 1 条评论 ·
查看 microsoft/vscode-cpptools 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
0xMiden/bridge-portal#132 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
area:tools bug good first issue help wanted priority:P2
难度 2/5 1-3 小时 新手友好度 90/100
TaewoooPark/Motifcode#14 ·
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
newrelic-experimental/preflight#793 · 1 条评论 ·