Skip to content
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

Semantic Highlighting hangs for the following C++ code #10105

Closed
SingularityAzure opened this issue Nov 3, 2022 · 3 comments
Closed

Semantic Highlighting hangs for the following C++ code #10105

SingularityAzure opened this issue Nov 3, 2022 · 3 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Milestone

Comments

@SingularityAzure
Copy link

SingularityAzure commented Nov 3, 2022

Environment

  • OS and Version: Windows 10 Pro 21H1
  • VS Code Version: 1.73.0
  • C/C++ Extension Version: v1.12.4
  • Other extensions you installed (and if the issue persists after disabling them): Issue occurs when C/C++ is the only enabled extension, and goes away when C/C++ is disabled.

Bug Summary and Steps to Reproduce

Bug Summary:

The following code causes semantic highlighting for C++ to stop working. When trying to Inspect Editor Tokens and Scopes, where it would normally describe the token just shows "Loading..." indefinitely.
The code compiles successfully with MSVC.

Steps to reproduce:

  1. Paste code into VSCode and save it as a .cpp file somewhere.
  2. Press F1 and select Developer: Inspect Editor Tokens and Scopes

Expected behavior

Semantic highlighting should work with this code.

Code sample and Logs

#include <utility>

template <typename T> struct NonConst;
template <typename T> struct NonConst<T const&> { using type = T&; };
template <typename T> struct NonConst<T const*> { using type = T*; };

#define NON_CONST_MEMBER_FUNC(func)                                                                \
	template <typename... T>                                                                       \
	auto func(T &&...a) -> typename NonConst<decltype(func(a...))>::type {                         \
		return const_cast<decltype(func(a...))>(std::as_const(*this).func(std::forward<T>(a)...)); \
	}


struct Foo {
	int val;
	const int& Get() const {
		return val;
	}
	NON_CONST_MEMBER_FUNC(Get);
};

int main() {
	Foo foo;
	foo.Get() = 3;
	return foo.Get();
}

This happens in an empty workspace, regardless of where the file is placed, as well as in a project.

-------- Diagnostics - 11/2/2022, 10:35:19 PM
Version: 1.12.4
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.19041.0",
    "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe",
    "cStandard": "c17",
    "intelliSenseMode": "windows-msvc-x64",
    "cppStandard": "c++17",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": true,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ E:\Productions\Programming\VSCode Workspaces\test.cpp ]:
    E:\Productions\Programming\VSCode Workspaces\test.cpp
Translation Unit Configurations:
[ E:\Productions\Programming\VSCode Workspaces\test.cpp ]: not ready
    Process ID: 15480
    Memory Usage: 0 MB
    Compiler Path: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe
    Includes:
        C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\INCLUDE
        C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\ATLMFC\INCLUDE
        C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM
        C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT
        C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED
        C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT
        C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 0 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 4871
loggingLevel: Debug
cpptools/didChangeCppProperties
Attempting to get defaults from C compiler in "compilerPath" property: 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe'
Code browsing service initialized
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe'
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/CPPWINRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/SHARED/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/UCRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/UM/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/WINRT/ will be indexed
  Folder: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.31.31103/ATLMFC/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.31.31103/INCLUDE/* will be indexed
cpptools/didChangeSettings
Discovering files...
IntelliSense Engine = Default.
Enhanced Colorization is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Autocomplete is enabled.
textDocument/didOpen: E:\Productions\Programming\VSCode Workspaces\test.cpp
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: E:\Productions\Programming\VSCode Workspaces\test.cpp
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/CPPWINRT/
  tag parsing file: E:\Productions\Programming\VSCode Workspaces\test.cpp
cpptools/getCodeActions: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 2)
cpptools/getInlayHints: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 3)
sending compilation args for E:\Productions\Programming\VSCode Workspaces\test.cpp
  include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\INCLUDE
  include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\ATLMFC\INCLUDE
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT
  define: _DEBUG
  define: UNICODE
  define: _UNICODE
  stdver: ms_c++17
  intelliSenseMode: windows-msvc-x64
Checking for syntax errors: E:\Productions\Programming\VSCode Workspaces\test.cpp
Queueing IntelliSense update for files in translation unit of: E:\Productions\Programming\VSCode Workspaces\test.cpp
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/SHARED/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/UCRT/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/UM/
cpptools/getCodeActions: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 4)
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.19041.0/WINRT/
  Processing folder (non-recursive): C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.31.31103/ATLMFC/INCLUDE
  Processing folder (non-recursive): C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/TOOLS/MSVC/14.31.31103/INCLUDE
  Discovering files: 4871 file(s) processed
  0 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
  Parsing: 0 files(s) processed
Done parsing remaining files.
cpptools/finishUpdateSquiggles
Update IntelliSense time (sec): 0.398
textDocument/hover: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 5)
IntelliSense process crash detected.
IntelliSense engine is not responding. Using the Tag Parser instead.
using Tag Parser for quick info
IntelliSense process crash detected.
cpptools/getCodeActions: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 6)
cpptools/getSemanticTokens: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 7)
cpptools/getCodeActions: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 8)
cpptools/getDocumentSymbols: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 9)
cpptools/getDocumentSymbols
cpptools/getFoldingRanges: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 10)
Checking for syntax errors: E:\Productions\Programming\VSCode Workspaces\test.cpp
Update IntelliSense time (sec): 0
cpptools/getInlayHints: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 11)
cpptools/getInlayHints: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 12)
textDocument/hover: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 13)
Resetting IntelliSense server: E:\Productions\Programming\VSCode Workspaces\test.cpp
sending compilation args for E:\Productions\Programming\VSCode Workspaces\test.cpp
  include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\INCLUDE
  include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\ATLMFC\INCLUDE
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT
  define: _DEBUG
  define: UNICODE
  define: _UNICODE
  stdver: ms_c++17
  intelliSenseMode: windows-msvc-x64
Request canceled: 13
textDocument/hover: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 14)
textDocument/hover: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 15)
IntelliSense engine is not responding. Using the Tag Parser instead.
using Tag Parser for quick info
IntelliSense process crash detected.
textDocument/hover: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 16)
Resetting IntelliSense server: E:\Productions\Programming\VSCode Workspaces\test.cpp
sending compilation args for E:\Productions\Programming\VSCode Workspaces\test.cpp
  include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\INCLUDE
  include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\VC\TOOLS\MSVC\14.31.31103\ATLMFC\INCLUDE
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT
  define: _DEBUG
  define: UNICODE
  define: _UNICODE
  stdver: ms_c++17
  intelliSenseMode: windows-msvc-x64
Checking for syntax errors: E:\Productions\Programming\VSCode Workspaces\test.cpp
Queueing IntelliSense update for files in translation unit of: E:\Productions\Programming\VSCode Workspaces\test.cpp
cpptools/finishUpdateSquiggles
Update IntelliSense time (sec): 0.303
cpptools/textEditorSelectionChange
textDocument/documentHighlight: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 17)
cpptools/getCodeActions: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 18)
cpptools/getSemanticTokens: E:\Productions\Programming\VSCode Workspaces\test.cpp (id: 19)

Screenshots

example

Additional context

No response

@browntarik browntarik self-assigned this Nov 3, 2022
@browntarik
Copy link
Contributor

Thank you for reporting this, it seems like the addition of the Foo struct in main is causing a memory issue and makes the extension crash. Currently looking into this issue further.

@browntarik
Copy link
Contributor

browntarik commented Nov 3, 2022

It looks like this is an error with Visual Studio as we share the same intellisense codebase, I will be filing a bug against their source as that is where the fix will be. You can track this issue to see when it is fixed by the VS team. (1665366)

@browntarik browntarik added this to the Tracking milestone Nov 3, 2022
@browntarik browntarik added the Visual Studio Inherited from Visual Studio label Nov 3, 2022
@sean-mcmanus sean-mcmanus modified the milestones: Tracking, 1.14 Jan 3, 2023
@browntarik browntarik added the fixed Check the Milestone for the release in which the fix is or will be available. label Jan 4, 2023
@sean-mcmanus sean-mcmanus modified the milestones: 1.14, 1.14.0 Jan 4, 2023
@sean-mcmanus
Copy link
Collaborator

The fix is available with 1.14.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.14.0

@browntarik browntarik removed their assignment Feb 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

3 participants