-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
lldb-mi freezes on MacOS when breaking near uninitialised variables #7240
Comments
lldb-mi seems to already have some issues being slow debugging as per #1899 (comment). For Apple Silicon, it will be slow since both the Debug Adapter (MIEngine) and lldb-mi will both be running in emulation. To fix the latter, it is dependent on #7035 |
Please note, this issue applies equally to Intel machines (I mention Apple Silicon only to be thorough). Also, I have left It in this high cpu, high memory state for "some time" (multiple minutes) - it doesn't seem to recover (so less about it being slow, and more about it getting stuck). cpptools no longer responds, except for cancelling debugging (but this leaves lldb-mi running in the background eating cpu and rapidly draining battery). This ~6 line sample is enough to break the debugging experience entirely, but personally I've encountered these symptoms a couple of times in actual code, although then I think it was an uninitialised std::vector that was the trigger. Anecdotally it seems like the debugger is reaching in to the uninitiated memory forever to resolve values for the local variables view. |
+1 for this issue, macOS Catalina 10.15.7, Intel CPU.
|
Same problem here. Would like to know how to address it. |
I have recompiled my lldb-mi with this patch:
|
Same problem here |
I just experienced this a few minutes ago. I am on MacOS Monterey, v12.3.1, Intel CPU. A few quick Google searches led me here. I'm glad to see that it's an issue that's still getting attention. |
This helped me to avoid the problem for now. |
Hey guys, do you have a solution for Linux users? |
Hey, any news on this? |
I do not think this is a VSCode issue. This is truly a problem with the lldb. See my patch above. lldb is out-of-bounds-ing on walking uninitialized variables with garbage values on things like internal counters and sizes. My quick yet brutal fix is to limit these things to 64. Unfortunately, VSCode tries to render all local variables in the current scope. And when it reaches one of those not-yet-initialized vars, it behaves like that. |
As a workaround, I installed CodeLLDB. It fixed the issue. Still, vscode's own debugger got lldb to use all the memory in my machine, which in turn made it unresponsive and I had to restart it. |
CodeLLDB is fine |
I have a bad feeling that CodeLLDB doesn't work now too. |
@bobbrow @WardenGnaw Is there any change of this getting fixed? It seems this issue is specific to Apple Silicon. What about Windows on arm? |
Nope this happens also on older Intel macs |
+1, I'm on Intel Mac and have the same issue. It hurts so bad during debug that in a new code I always initialize all local vars :) |
Is it working normally? |
@shiretu Would you consider improving it and then submit it to lldb-mi? |
This is still happening with cpptools v1.18.5. I disabled the "Variables" view of the debugger so I can get some work done. Mouse hover on a variable still shows the variables when needed. |
I actually had it freeze again after removing the file @jamesjuett
But hiding the variables section in the debug window does work (rerunning after hiding) |
This issue still persists |
This is an issue with synthetic child providers. For STL classes you often don't want to see the actual children of a
And then with the variable that causes the problem run:
The --raw option will disable the synthetic child plug-in. These synthetic plugins can either be natively compiled into lldb, or they can be python modules that add the support. If they are python then it is usually easy to fix right away. If the synthetic child provider is compiled into LLDB, then a new version of LLDB will need to be distributed. This formatter does seem to have issues. I just compiled your example and ran this in the command line:
As you can see we stopped asking for children when we reached the
So we think there are 4299233552 children to show. This value is way to easy to mess up because there isn't much we can do to know when the values are bad. We can check that |
In this case the provider is built in:
|
So the question is: is the MI plug-in asking and producing that many children for this variable and that is what is taking the time and blowing up memory? If so, it should stop creating children for a variable when it hits the |
|
Thanks for the info @sunshaoce . I was able to work around the issue by building Obviously any update to the extension would cause the file to be overwritten. Not sure how to update it inside the cpptools extension directly. This whole "downloading" section seems outdated https://github.com/microsoft/vscode-cpptools/blob/main/CONTRIBUTING.md#about-the-code -- there is no |
OS and Version: MacOS 14.6.1 (Sonoma) Similar issue, but for me the debugger crashes
Tried building The workaround of hiding the Variables view from #7240 (comment) works. Downgrading Xcode to 15.4 (and thus to |
Thank you for this tip. Is a great workaround. |
Type: Debugger
Describe the bug
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 withdebugserver
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:
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
launch.json
tasks.json
The tail of my engine logging output at the point where the debugger has frozen on a breakpoint, looks like:
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:
The text was updated successfully, but these errors were encountered: