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

language service features not working for WSL config #3052

Closed
haovic opened this issue Jan 18, 2019 · 25 comments
Closed

language service features not working for WSL config #3052

haovic opened this issue Jan 18, 2019 · 25 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@haovic
Copy link

haovic commented Jan 18, 2019

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 Ver 1803 (64-bit)
  • VS Code Version: 1.30.2
  • C/C++ Extension Version: 0.21.0 (and 0.20.1)
  • Other extensions you installed (and if the issue persists after disabling them): Python, sftp

My intelliSense and syntax error checking (red squiggles) do not work at all, and I am getting massive amounts of the errors in the title when I check the Developer Tools. I believe the issues to be related. Whenever I type in a C++ file (even after waiting so not like issue #2807 ), tons of these errors appear.

To Reproduce

  1. Open a folder
  2. Create a new .cpp file
  3. Type anything

Expected behavior

IntelliSense suggestions/Syntax Error Highlighting appears.

Actual behavior
If Developer Console is open, number of 'map' errors increases linearly with amount of text typed. Only most basic possible suggestions appear (even #include is not auto-completed) and no syntax error checking.

Screenshots

image

Additional context

I've also tried different combinations of almost all settings regarding intelliSense, as well as reinstalling both the extension as well as VSCode itself (reinstalling meaning I wiped every trace of VSCode from multiple system folders). The Insider Edition does not solve this issue either. Here is an example of my c_cpp_properties.json

{
    "configurations": [
        {
            "name": "WSL",
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

I know that I do not have an includePath in this example, but I heard it might be worth trying to take it out. Currently, I have intelliSense fallback disabled. I think it's also worth mentioning that tag parser/fuzzy works to the extent of autocomplete when turned on, but syntax highlighting continues to fail. intelliSense works for Python.

Copy paste of the error msgs:

TypeError: Cannot read property 'map' of undefined
	at asCompletionResult (C:\Users\<user>\.vscode\extensions\ms-vscode.cpptools-0.20.1\node_modules\vscode-languageclient\lib\protocolConverter.js:74:51)
	at <anonymous>

    t.log | @ | /C:/Users/<user>…rkbench.main.js:303
  | t._logExtensionHostMessage | @ | /C:/Users/<user>…kbench.main.js:3270
  | (anonymous) | @ | /C:/Users/<user>…kbench.main.js:3266
  | emitTwo | @ | events.js:126
  | emit | @ | events.js:214
  | emit | @ | internal/child_process.js:772
  | _combinedTickCallback | @ | internal/process/next_tick.js:141
  | _tickCallback | @ | internal/process/next_tick.js:180
@bobbrow
Copy link
Member

bobbrow commented Jan 18, 2019

Thank you for reporting the issue. This appears to be a duplicate of #2807 which will be fixed in our next release.

@haovic
Copy link
Author

haovic commented Jan 18, 2019

Are you sure that the fix for #2807 resolves this problem? It was mentioned in #2807 that the error only occurred when immediately editing a file, and that it appeared to have no adverse effects on anything else. In this case it appears to completely prevent intelliSense from functioning. Also, is there any ETA for the next release?

@bobbrow
Copy link
Member

bobbrow commented Jan 19, 2019

Sorry, I read the title and assumed this was the same issue. We plan to release an update on Tuesday next week. You can install the pre-release version by downloading the .vsix from here: https://github.com/Microsoft/vscode-cpptools/releases/tag/0.21.0-insiders4 or changing the setting: "C_Cpp.updateChannel": "Insiders"

@bobbrow bobbrow reopened this Jan 19, 2019
@bobbrow bobbrow changed the title IntelliSense failing "TypeError: Cannot read property 'map' of undefined at asCompletionResult" language service features not working for WSL config Jan 19, 2019
@bobbrow bobbrow removed the duplicate label Jan 19, 2019
@bobbrow
Copy link
Member

bobbrow commented Jan 19, 2019

And if you remove includePath from your c_cpp_properties.json we will insert the default value: ["$workspaceFolder}/**"] for you.

If you could enable logging and share the logs with us, we can investigate further.

@haovic
Copy link
Author

haovic commented Jan 20, 2019

Thanks for the response. I've tried the pre-release version and now the errors in the Developer Console are gone. However, intelliSense and syntax error checking are still not working and I am getting a similar issue to #1377 with the following output in the logs:

initialized
workspace/didChangeConfiguration
IntelliSense Engine = Default.
Autocomplete is enabled.
Error squiggles are enabled.
File exclude: **/.git
File exclude: **/.svn
File exclude: **/.hg
File exclude: **/CVS
File exclude: **/.DS_Store
File exclude: **/.vscode
Search exclude: **/node_modules
Search exclude: **/bower_components
Search exclude: **/.vscode
textDocument/didOpen
cpptools/queryCompilerDefaults
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe'
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe'
cpptools/activeDocumentChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/didChangeFolderSettings
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe'
Code browsing service initialized
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe'
  Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2017/ENTERPRISE/VC/TOOLS/MSVC/14.16.27023/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2017/ENTERPRISE/VC/TOOLS/MSVC/14.16.27023/ATLMFC/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/UM/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/UCRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/SHARED/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/WINRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/CPPWINRT/ will be indexed
  Folder: C:/USERS/VICTOR HAO/DESKTOP/TEST2/ will be indexed
textDocument/didOpen
Populate include completion cache.
Discovering files...
textDocument/codeAction
  Processing folder (non-recursive): C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2017/ENTERPRISE/VC/TOOLS/MSVC/14.16.27023/INCLUDE
  tag parsing file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\VC\TOOLS\MSVC\14.16.27023\INCLUDE\CODEANALYSIS\SOURCEANNOTATIONS.H
Failed to spawn process. Error: 193 ()
Failed to spawn IntelliSense process: Unable to start child process!
Shutting down IntelliSense server: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Checking for syntax errors: file:///c%3A/Users/Victor%20Hao/Desktop/Test2/hello.cpp
Failed to spawn process. Error: 193 ()
Failed to spawn IntelliSense process: Unable to start child process!
Shutting down IntelliSense server: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Failed to create IntelliSense client. Can't create intellisense client for C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
  Processing folder (non-recursive): C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2017/ENTERPRISE/VC/TOOLS/MSVC/14.16.27023/ATLMFC/INCLUDE
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/UM/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/UCRT/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/SHARED/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/WINRT/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.17763.0/CPPWINRT/
  Processing folder (recursive): C:/USERS/VICTOR HAO/DESKTOP/TEST2/
  Discovering files: 4741 file(s) processed
  0 file(s) removed from database
Done discovering files.
Parsing remaining files...
  Parsing: 0 files(s) processed
Done parsing remaining files.
cpptools/textEditorSelectionChange
Database safe to open
cpptools/activeDocumentChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
textDocument/codeAction
cpptools/textEditorSelectionChange
textDocument/codeAction
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/completion
auto_complete::handle_completion: file:///c%3A/Users/Victor%20Hao/Desktop/Test2/hello.cpp (6:6)
Offering completion
  tag parsing file: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
completionItem/resolve
Failed to spawn process. Error: 193 ()
Failed to spawn IntelliSense process: Unable to start child process!
Shutting down IntelliSense server: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Failed to create IntelliSense client. Can't create intellisense client for C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
completionItem/resolve
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/completion
auto_complete::handle_completion: file:///c%3A/Users/Victor%20Hao/Desktop/Test2/hello.cpp (6:11)
Offering completion
  tag parsing file: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
completionItem/resolve
Failed to spawn process. Error: 193 ()
Failed to spawn IntelliSense process: Unable to start child process!
Shutting down IntelliSense server: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Failed to create IntelliSense client. Can't create intellisense client for C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
completionItem/resolve
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/completion
auto_complete::handle_completion: file:///c%3A/Users/Victor%20Hao/Desktop/Test2/hello.cpp (6:16)
Offering completion
  tag parsing file: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
completionItem/resolve
Failed to spawn process. Error: 193 ()
Failed to spawn IntelliSense process: Unable to start child process!
Shutting down IntelliSense server: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Failed to create IntelliSense client. Can't create intellisense client for C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/didChange
cpptools/textEditorSelectionChange
completionItem/resolve
textDocument/codeAction
textDocument/didChange
cpptools/textEditorSelectionChange
textDocument/codeAction
Checking for syntax errors: file:///c%3A/Users/Victor%20Hao/Desktop/Test2/hello.cpp
  tag parsing file: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Failed to spawn process. Error: 193 ()
Failed to spawn IntelliSense process: Unable to start child process!
Shutting down IntelliSense server: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Failed to create IntelliSense client. Can't create intellisense client for C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Database safe to open
Checking for syntax errors: file:///c%3A/Users/Victor%20Hao/Desktop/Test2/hello.cpp
Failed to spawn process. Error: 193 ()
Failed to spawn IntelliSense process: Unable to start child process!
Shutting down IntelliSense server: C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP
Failed to create IntelliSense client. Can't create intellisense client for C:\USERS\VICTOR HAO\DESKTOP\TEST2\HELLO.CPP

I noticed that someone posted regarding this issue 5 days ago in that thread here, so this issue might be related. If you need any additional details please let me know.

@sean-mcmanus
Copy link
Collaborator

You're hitting:
ERROR_BAD_EXE_FORMAT
193 (0xC1)
%1 is not a valid Win32 application.
It appears that something is wrong with your Microsoft.VSCode.CPP.IntelliSense.Msvc.exe binary. I assume it won't run via the command line? Can you try re-installing? Via what method did you install the Insiders?

@haovic
Copy link
Author

haovic commented Jan 23, 2019

I have tried reinstalling both VSC Insiders as well as the cpp extension pre-release that bob provided. I downloaded VSC Insiders from the official VSC website and installed normally. To install the .vsix I went to extensions and chose to install from .vsix and opened the folder where the .vsix was located and chose the .vsix file.

I've located the Microsoft.VSCode.CPP.IntelliSense.Msvc.exe file in my .vscode-insiders\extensions\ms-vscode.cpptools-0.21.0-insiders4\bin directory. Double clicking it causes the command prompt to come up for a split-second and then disappear. Running it in command prompt does nothing (there's no output). When I've reinstalled I've also deleted the .vscode folder, so I think it's unlikely that the binary would be corrupted every time. From some basic googling, perhaps I am somehow missing a DLL? Any suggestions?

@sean-mcmanus
Copy link
Collaborator

Yeah, missing some required OS DLL is a possibility. Can you open the binary in a dependency checker such as http://www.dependencywalker.com/ and see if anything appears to be missing -- you should see 4 bogus errors and 2 bogus warnings that you can ignore, but if you see more, then that is a problem.

image

@haovic
Copy link
Author

haovic commented Jan 23, 2019

This is what popped up when I opened the file:
image

If you need the output of the modules window I can paste that as well, but for many of those .DLLs like API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL there was an "Error opening file. The system cannot find the file specified (2)."

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jan 23, 2019

I get the same the API-MS-WIN-CORE messages, so that is okay. There appears to be some issue with it loading 64-bit DLLs instead of the 32-bit ones. When you right-click to view the properties of Kernel32.dll does it show C:\Windows\SysWow64 ? Our binaries are 32-bit on Windows (64-bit on Mac/Linux).

@haovic
Copy link
Author

haovic commented Jan 23, 2019

It shows the location as C:\windows\system32

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jan 23, 2019

Is your OS 32-bit or 64-bit? It should show in your Settings->About page:

image

@haovic
Copy link
Author

haovic commented Jan 23, 2019

Oops I should've specified that in my original post. It is 64-bit.

@sean-mcmanus
Copy link
Collaborator

Does C:\Windows\SysWOW64 exist on your machine? Does kernel32.dll exist in that folder? It appears something on your machine is causing our process to want to incorrectly load the 64-bit DLLs instead of the 32-bit ones. Does this repro with the 0.21.0 release we just shipped?

@haovic
Copy link
Author

haovic commented Jan 23, 2019

kernel32.dll exists in that folder. The error persists with the 0.21.0 release.

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jan 23, 2019

If you open the Microsoft.VSCode.CPP.Extension.exe with the Dependency Walker does it show the same results (i.e. 64-bit DLLs)? If so, then it would suggest it's not related to the IntellSense process failure...unless there's some difference in our method of child process spawning versus how VS Code launches our main process.

@sean-mcmanus
Copy link
Collaborator

Also, have you ever gotten our IntelliSense process to work (i.e. is this a regression) or are you a new user? Are you able to use the Install Another Version... feature to select an older version that works?

@haovic
Copy link
Author

haovic commented Jan 24, 2019

Opening Microsoft.VSCode.CPP.Extension.exe with the Dependency Walker shows 64-bit DLLs as well. I'll try to do a little researching online as to what could be the issue. Do you have any suggestions?

I'm a new user and so far it hasn't ever worked.

EDIT: I also used Dependency Walker's 32-bit version and the paths for the DLLs are still the paths the 64-bit versions. I've also tried older versions up to a year old and they all have the "Failed to create IntelliSense client" issue albeit with less descriptive errors.

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jan 24, 2019

Can you run ProcMon (Process Monitor) https://docs.microsoft.com/en-us/sysinternals/downloads/procmon and see what errors or suspicious info it reports? You can filter on "Process Name is Microsoft.VSCode.CPP.IntelliSense.Msvc.exe". You should see a Process Start operation and Load Image operations should be called on various DLLs -- the last events shown may give a clue to the problem. You may not want to run Proc Mon for too long though, because it can use too much system resources and potentially cause "issues".

One possibility is that you have some incorrect registry key relating to WOW64 that is causing the wrong DLLs to load when we call our CreateProcess, see https://docs.microsoft.com/en-us/windows/desktop/Dlls/dynamic-link-library-search-order . We haven't gotten any other reports like this yet so it seems like some rare OS configuration issue.

If you have enabled Win10 case-sensitivity enabled on the path where our binary exists that might lead to an issue like this (we don't currently support/test that scenario).

@haovic
Copy link
Author

haovic commented Jan 24, 2019

Case-sensitivity is not enabled on the path. I've attached the output that Procmon produces when I try running Microsoft.VSCode.CPP.IntelliSense.Msvc.exe manually. Nothing was popping up in Procmon when I was typing in VSCode, even though errors were showing up in the VSCode output. I tried taking a look at the Procmon output myself, but I'm no expert and couldn't tell which non-successes were okay and which ones weren't.

Logfile.xlsx

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jan 24, 2019

The ProcMon from the manual run appears okay to me -- it's using the 32-bit SysWOW64. The fact that no ProcMon data appears via our extension must mean that there is something special with how our main process is launching the child process. Can you run ProcMon, open some (small) workspace folder so our main process launches, clear the ProcMon log, change your includePath to an empty array and your compilerPath to an empty string (to reduce the ProcMon noise), change the filter to Microsoft.VSCode.CPP.Extension.exe (make sure that process is using 0 CPU first though), then open a C/C++ file. This should cause a Process Create operation to get logged for the Microsoft.VsCode.CPP.IntelliSense.Msvc.exe process or some other sort of failed operation related to that.

@sean-mcmanus
Copy link
Collaborator

@haovic From the other report of this, it sounds like the repro may occur when your user name has a space and you also have a file that matches the first word of your user name in the Users folder, so deleting that file might resolve your issue (we're still investigating a fix).

@sean-mcmanus sean-mcmanus added this to the February 2019 milestone Feb 4, 2019
@sean-mcmanus sean-mcmanus added the investigate: repro This issue's repro steps needs to be investigated/confirmed label Feb 4, 2019
@haovic
Copy link
Author

haovic commented Feb 4, 2019

Hi Sean, that was exactly the issue! I had a file named "Victor" in my Users folder that was automatically generated by Xilinx Vivado if anyone else happens to have the same thing happen to them.

I also think it's worth mentioning that I realized this week that the issue wasn't just limited to VSCode or this extension, as I made a new C++ project in Visual Studio 2017 Enterprise and intelliSense didn't work for that as well. However, intelliSense did work when I opened old projects or copy pasted old project directories within the same directory. However, it didn't work if I tried to copy paste an old project to a different directory. Autocomplete also was not working for Sublime Text when I tried installing that, so it's possible that somehow all of this is related.

It may also be helpful to know that my Visual Studio 2017 intelliSense was working perfectly fine before I installed an update during the second week of January in addition to installing Python for VS2017. I installed VSCode immediately afterwards during that same session, so it's possible that some update to VS2017 broke something out of my control. Just food for thought.

I was pretty busy this week so sorry for the late reply. If you need me to run any other tests, please let me know. I'm immensely grateful for your help, and keep up the great work!

EDIT: intelliSense for new VS2017 projects is now working again as well! Sublime Text autocomplete still doesn't work so that may have just been a mistake setting it up on my side.

@sean-mcmanus sean-mcmanus self-assigned this Feb 7, 2019
@sean-mcmanus sean-mcmanus added fixed Check the Milestone for the release in which the fix is or will be available. and removed investigate: repro This issue's repro steps needs to be investigated/confirmed labels Feb 7, 2019
@sean-mcmanus sean-mcmanus removed their assignment Feb 8, 2019
@sean-mcmanus
Copy link
Collaborator

The bug with IntelliSense not working on Windows when the username has a space in it should be fixed with 0.22.0-insiders2: https://github.com/Microsoft/vscode-cpptools/releases .

@starkblitz
Copy link

starkblitz commented Mar 20, 2019

Intellisense is working perfectly with the 0.22 update! Thank you so much!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2020
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
Projects
None yet
Development

No branches or pull requests

4 participants