microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.45k stars 1.53k forks source link

Possible memory leak related to `lldb-mi` #10176

Open hackroid opened 1 year ago

hackroid commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: lldb-mi kept eating memory (about +500MB/s) when debugging until the whole macOS froze.

Steps to reproduce:

  1. Debug the following snippet with the provided environment above

    
    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    int main()
    {
        vector<int> nn(4, 0);
        for (size_t i = 0; i < 4; i++) {
            int tt;
            cin >> tt;
            nn[i] = tt;
        }
        vector<int> k;
        cout << nn[1];
        return 0;
    }
  2. With the config(launch/task) provided below
  3. Make a break point at line 14: vector<int> k;
  4. Start debugging
  5. Input 4 integers 5 2 6 1 , press enter, then be like this debug
  6. Variables monitor will show nothing but loading... var
  7. Open Activity Monitor (macOS app), lldb-mi start using lots of memory act
  8. Stop debugging, close the terminal windows, lldb-mi still won't stop and keep eating memory
  9. Can stop lldb-mi only by force quit.

Debugger Configurations

{
    "configurations": [
        {
            "name": "clang++ dbg",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb",
            "preLaunchTask": "C/C++: clang++ build active file",
            "logging": { "engineLogging": true, "trace": true, "traceResponse": true }
        }
    ],
    "version": "2.0.0"
}

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

Debugger Logs

https://blog.hackroid.com/debug-log.html

Other Extensions

No response

Additional Information

No response

hackroid commented 1 year ago

Small changes to the code will avoid the problem, but, just wondering why. Like: line 10: move int tt; outside the for loop. Or like: line 9: change size_t to int.

H-G-Hristov commented 1 year ago

It's broken. I switched to CodeLLDB for debugging on macOS.

https://github.com/microsoft/vscode-cpptools/issues/9831

bobbrow commented 1 year ago

@WardenGnaw have you seen this?

WardenGnaw commented 1 year ago

Yeah, this is due to the external dependency the debugger uses lldb-mi.

zanmato1984 commented 1 year ago

Observed the exact same issue, i.e., local variable keep loading, lldb-mi showing significant memory consumption after a while.

OS

macOS Ventura Version 13.2.1 (22D68)

VSCode

Version: 1.76.2 Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884 Date: 2023-03-14T17:53:46.528Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Darwin arm64 22.3.0 Sandboxed: No

zanmato1984 commented 1 year ago

It's broken. I switched to CodeLLDB for debugging on macOS.

9831

This works for me too. Thanks bro!

denniskb commented 1 month ago

Same issue when trying to step through a googletest test case that involves popen(). Stepping through any other code is smooth and leak-free.