microsoft / vscode-cpptools

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

RAM usage skyrocketing when saving file with infinite recursive template function instantiation #10514

Open lukas-kandora opened 1 year ago

lukas-kandora commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: RAM usage of process cpptools-srv.exe ("C/C++ IntelliSense Server for Visual Studio Code") quickly rises infinitely when saving a .cpp-file with the following code snippet:

template<typename... Args>
static constexpr auto fun()
{
    return fun<Args..., void>();
}
static constexpr auto value = fun<>(); // (a)

Commenting out line (a) and saving prevents this only after killing the process manually. Tested in otherwise empty project folder.

Steps to reproduce:

  1. Create a new folder
  2. Open folder in VS Code
  3. Create and save a .cpp-file with the content shown above.

Configuration and Logs

-------- Diagnostics - 2/13/2023, 8:43:49 PM
Version: 1.13.9
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22000.0",
    "compilerPath": "E:/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ D:\Users\LukasK\Desktop\New folder\file.cpp ]:
    D:\Users\LukasK\Desktop\New folder\file.cpp
Translation Unit Configurations:
[ D:\Users\LukasK\Desktop\New folder\file.cpp ]: not ready
    Process ID: 14216
    Memory Usage: 1561 MB
    Compiler Path: E:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\cl.exe
    Includes:
        E:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include
        E:\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include
        E:\Windows Kits\10\Include\10.0.22000.0\um
        E:\Windows Kits\10\Include\10.0.22000.0\ucrt
        E:\Windows Kits\10\Include\10.0.22000.0\shared
        E:\Windows Kits\10\Include\10.0.22000.0\winrt
        E:\Windows Kits\10\Include\10.0.22000.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
    Other Flags:
        --using_directory
        E:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\lib\x86
        --using_directory
        E:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\lib\x86\store\references
        --using_directory
        E:\Windows Kits\10\UnionMetadata\10.0.22000.0
        --using_directory
        E:\Windows Kits\10\References\10.0.22000.0
        --using_directory
        C:\Windows\Microsoft.NET\Framework\v4.0.30319
Total Memory Usage: 1561 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5072

Other Extensions

No response

Additional context

No response

browntarik commented 1 year ago

Thank you for submitting this issue! We are currently looking into a fix.

browntarik commented 1 year ago

We have filed a bug with the Visual Studio team (1746684) and a fix should be made soon. This GitHub issue will track the progress of the fix.