vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

extension not working correctly on Manjaro Linux

Open vidmartin opened this issue 5 years ago • 11 comments

Bug type: Language Service

Describe the bug

  • OS and Version: 5.13.19-2-MANJARO
  • VS Code Version: 1.62.3
  • C/C++ Extension Version: 1.7.1
  • Other extensions you installed (and if the issue persists after disabling them): I will get to that
  • If using SSH remote, specify OS of remote machine: not using SSH remote
  • The C/C++ extension just doesn't work properly on my system. I tried reinstalling vs code many times - both from Arch User Repository and from snap - and it never worked correctly, even with no other extensions installed. The problems that I'm encountering are:
    • when I do "go to definition", instead of finding the symbol in the current tab, a new tab is opened. When I try to "go to definition" again, it says "no definition found for ...", until I close both tabs.
    • IntelliSense is very slow and often stops working until I click "restart intellisense for active file"
    • sometimes, syntax highlighting breaks down and starts highlighting things incorrectly
    • when declaring variables with structs / enums, the type name doesn't get syntax highlighting
    • sometimes, linting breaks down and stops updating, so even after I fix whatever is underlined with red squiggles, the error is still highlighted, as if the code checker was lost in the past

Steps to reproduce

  1. install VS Code on Manjaro
  2. install this extension
  3. write code for a while until you encounter any of the issues above

Expected behavior working "go to definition", working IntelliSense, working syntax highlighting, working linting

Code sample and logs

  • Code sample - this issue is not related to my code, I tested it on many different projects. Generally, I had a folder containing one to three small .c or .cpp files opened - so the issues I'm describing probably aren't performance related.

  • Configurations in c_cpp_properties.json: it doesn't work with the default configuration. It doesn't work after changing compiler path to /usr/bin/g++ or /usr/bin/gcc. It doesn't work after changing intelliSenseMode to linux-gcc-x64.

  • Logs from running C/C++: Log Diagnostics from the VS Code command palette

      -------- Diagnostics - 11/26/2021, 5:57:12 PM
      Version: 1.7.1
      Current Configuration:
      {
          "name": "Linux",
          "includePath": [
              "${workspaceFolder}/**"
          ],
          "defines": [],
          "compilerPath": "/usr/bin/g++",
          "cStandard": "c17",
          "cppStandard": "c++14",
          "intelliSenseMode": "linux-gcc-x64",
          "compilerPathIsExplicit": true,
          "cStandardIsExplicit": true,
          "cppStandardIsExplicit": true,
          "intelliSenseModeIsExplicit": true,
          "compilerArgs": [],
          "mergeConfigurations": false,
          "browse": {
              "path": [
                  "${workspaceFolder}/**"
              ],
              "limitSymbolsToIncludedHeaders": true
          }
      }
      Translation Unit Mappings:
      [ /mnt/d/FIT/bi-pa1/du-repo/hw05/zbozi3.cpp ]:
          /mnt/d/FIT/bi-pa1/du-repo/hw05/zbozi3.cpp
      Translation Unit Configurations:
      [ /mnt/d/FIT/bi-pa1/du-repo/hw05/zbozi3.cpp ]:
          Process ID: 19040
          Memory Usage: 22 MB
          Compiler Path: /usr/bin/g++
          Includes:
              /usr/include/c++/11.1.0
              /usr/include/c++/11.1.0/x86_64-pc-linux-gnu
              /usr/include/c++/11.1.0/backward
              /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include
              /usr/local/include
              /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed
              /usr/include
          Standard Version: c++14
          IntelliSense Mode: linux-gcc-x64
          Other Flags:
              --g++
              --gnu_version=110100
      Total Memory Usage: 22 MB
    

Screenshots

2021-11-26_17-47

2021-11-26_17-48

2021-11-26_17-49

2021-11-26_17-51

2021-11-26_17-22

vidmartin avatar Nov 26 '21 17:11 vidmartin

Hi @vidmartin . Do you see similar issues with a simple project? If basic functionality is working as expected, the issues you are seeing may not be specific to Manjaro Linux. If there were a platform issue, I would expect it would not function at all, or certain features would fail consistent in simple scenarios.

There are 2 types of colorization that can occur, syntactic/lexical and semantic. Are you seeing issues with placement of syntax colorization, or only semantic colorization? VS Code provides syntactic/lexical colorization. The C/C++ extension provides semantic colorization based on IntelliSense. If a file is not parsed correctly due to prior errors, or if there is a bug causing the IntelliSense parser to crash, that could result in lack of colorization. Could you try enabling "C_Cpp.loggingLevel": "Debug", and monitoring the output of the C/C++ output channel for indications that the IntelliSense process has crashed? If so, the next step would be to try to isolate the code that triggers the crash. Most of the issues you mentioned would be potential symptoms of the IntelliSense process crashing.

Colorization being applied to an incorrect range might be a VS Code issue. Does that occur consistently? Does it require making a code change earlier in the file? The C/C++ extension receives a request to provide semantic tokens for a specific version of a file, and VS Code should cancel that request and request again if the file has changed. If it receives colorization for a file that has since changed, it should adjust those ranges or request again based on the new contents. VS Code is responsible for moving existing colorization around as the file is modified.

Colengms avatar Nov 29 '21 23:11 Colengms

Hi @vidmartin . Do you see similar issues with a simple project? If basic functionality is working as expected, the issues you are seeing may not be specific to Manjaro Linux. If there were a platform issue, I would expect it would not function at all, or certain features would fail consistent in simple scenarios.

There are 2 types of colorization that can occur, syntactic/lexical and semantic. Are you seeing issues with placement of syntax colorization, or only semantic colorization? VS Code provides syntactic/lexical colorization. The C/C++ extension provides semantic colorization based on IntelliSense. If a file is not parsed correctly due to prior errors, or if there is a bug causing the IntelliSense parser to crash, that could result in lack of colorization. Could you try enabling "C_Cpp.loggingLevel": "Debug", and monitoring the output of the C/C++ output channel for indications that the IntelliSense process has crashed? If so, the next step would be to try to isolate the code that triggers the crash. Most of the issues you mentioned would be potential symptoms of the IntelliSense process crashing.

Colorization being applied to an incorrect range might be a VS Code issue. Does that occur consistently? Does it require making a code change earlier in the file? The C/C++ extension receives a request to provide semantic tokens for a specific version of a file, and VS Code should cancel that request and request again if the file has changed. If it receives colorization for a file that has since changed, it should adjust those ranges or request again based on the new contents. VS Code is responsible for moving existing colorization around as the file is modified.

Hello, thanks for the reply. I'm seeing these issues even with the simplest projects, when having opened a folder containing one or two .cpp files.

I tried enabling "C_Cpp.loggingLevel": "Debug", but I don't know what to look for in the output channel. Is there a particular string, that I could search for in the output channel, to find some relevant messages?

The colorization issues with the colorization ranges not updating, such as in the last picture in my original post, is not happening very often for me. What is happening often is, that my custom types aren't colorized and are left white, as you can see in the picture before that.

Another thing that's bothering me, is that "go to definition", or clicking on a link in the terminal, doesn't navigate to the symbol in an already opened file, and instead opens the file in a second tab. However, what is interesting, is that when I open a file via the explorer, the type names are usually not colored, but autocompletion works; however, when I click "go to definition" and a new tab with the same file is opened, type names are highlighted correctly in this new tab, but autocompletion works only as long as the original tab is opened; once I close it, autocompletion no longer works in the tab that was opened by "go to definition". Maybe the type names are suddenly highlighted correctly, because the editor is using syntactic colorization instead of semantic in the tab opened by "go to definition"?

Also, I've noticed, that this problem with "go to definition" isn't exclusive to C/C++. I think I also encountered it in Rust and maybe in C#, however I'm not able to reproduce it right now. I'm not sure to which extent this is an issue caused by the C/C++ extension, and to which extent it is caused by VS Code itself. However, it seems that C/C++ editing is by far the most "broken".

vidmartin avatar Dec 05 '21 17:12 vidmartin

The "colorization going crazy" problem happened again. I'm attaching the logs from "C/C++" channel and "Extension host" channel as well as some screenshots. vscode-cpp-extension.log vscode-extension-host.log vscode-cpp-problem-img vscode-cpp-problem-img-2 vscode-cpp-problem-img-3 vscode-cpp-problem-img-4 vscode-cpp-problem-img-console

vidmartin avatar Dec 05 '21 19:12 vidmartin

I have some interesting observations. I usually launch VS Code through the terminal, specifying the directory to open as an argument. It seems that whether or not the issues I've described happen depends on this argument. If I open the terminal, cd into the directory I want and then run code ., everything seems to work correctly. However, when I use the absolute path, which actually goes through a symlink to another drive, as the argument, the issues I've described happen.

vidmartin avatar Dec 12 '21 14:12 vidmartin

Hi @vidmartin . I noticed a path into /mnt/d in your logs. Are you using WSL? I seem to recall a bug in WSL 1 in which it would not consistently reflect changes to files made in the other OS (maybe a caching issue?), leading to similar symptoms as you describe.

If not WSL, does 'd' refer to a Windows share? Do the same issues occur when working with a project not opened from a Windows file system through a mount point?

Could you elaborate on what you mentioned about symlinks? Does the same issue occur if you use a full path that does not involve symlinks?

Colengms avatar Dec 14 '21 01:12 Colengms

Hi @vidmartin . I noticed a path into /mnt/d in your logs. Are you using WSL? I seem to recall a bug in WSL 1 in which it would not consistently reflect changes to files made in the other OS (maybe a caching issue?), leading to similar symptoms as you describe.

If not WSL, does 'd' refer to a Windows share? Do the same issues occur when working with a project not opened from a Windows file system through a mount point?

Could you elaborate on what you mentioned about symlinks? Does the same issue occur if you use a full path that does not involve symlinks?

Hello @Colengms, I have dual boot with Windows 10 and Manjaro, but I only use Manjaro, I don't have WSL installed on Windows. /mnt/d is a mount point for a NTFS partition, where I have my projects. My home directory is on a different drive and I have multiple symbolic links for various directories in /mnt/d there. It seems that the issues occur when I launch VS Code with a path that "goes through" such a symbolic link. I'm not sure whether this happens for any symbolic link, or just if it refers to a location on another drive.

vidmartin avatar Dec 14 '21 11:12 vidmartin

I'm guessing it's failing due the case-sensitive difference in the file system (i.e. https://github.com/microsoft/vscode-cpptools/issues/1994). We don't support accessing Linux files from Windows.

sean-mcmanus avatar Dec 14 '21 17:12 sean-mcmanus

I'm guessing it's failing due the case-sensitive difference in the file system (i.e. #1994). We don't support accessing Linux files from Windows.

I'm not accessing Linux files from Windows, I'm creating the files on Linux and accessing them from Linux.

vidmartin avatar Dec 18 '21 13:12 vidmartin

Oh, this sounds like https://github.com/microsoft/vscode-cpptools/issues/4573 .

sean-mcmanus avatar Dec 20 '21 21:12 sean-mcmanus

Oh, this sounds like #4573 .

Yes, that is likely.

vidmartin avatar Dec 29 '21 12:12 vidmartin

Since this sounds like a duplicate of #4573 , closing this one as a dupe.

Colengms avatar Jan 10 '22 20:01 Colengms