microsoft / microsoft/vscode-cpptools

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

Open
#10,514 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug verified Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Microsoft Windows 10 Pro - 10.0.19045 Build 19045
  • VS Code Version: 1.75.1
  • C/C++ Extension Version: v1.13.9
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied recursive template case in a saved .cpp file and monitor cpptools-srv.exe while IntelliSense processes it. The payload names no source files or tests; done means saving the file no longer causes unbounded memory growth or requires manually killing the process.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, devtools
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.