microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.71k stars 29.08k forks source link

"Extension host terminated unexpectedly" when opening C# file #6318

Closed acastaner closed 7 years ago

acastaner commented 8 years ago

Whenever I open a C# file in VS Code, I get two error messages:

"Extension host terminated unexpectedly. Please reload the window to recover. [Reload Window]" Followed by "Error from the extension host: channel closed."

I'm using the CSharp extension (ms-vscode.csharp-0.3.7). Here's a screenshot:

https://imgur.com/8dGJuWK

Steps to Reproduce:

  1. Install the C# extension
  2. Open a C# file

Now the problem is, this issue happens only on one of my PCs (the one actually owned by my employer). The main differences with the other PCs I own are:

There are other differences of course, but these are the three biggest I can think of.

jrieken commented 8 years ago

@acastaner Just to be clear. This happens only and as soon as you open a C# file? Like you are happily working in a TypeScript file (with IntelliSense et al) and then when you open a C# file it crashes?

acastaner commented 8 years ago

Yes you are correct. I have tried with the reStructuredText and PowerShell extensions and they don't crash the window. Only the C# extension does.

jrieken commented 8 years ago

@DustinCampbell anything special you guys do on activate which might cause trouble on win7?

DustinCampbell commented 8 years ago

On activation, the C# extension tries to acquire OmniSharp

acastaner commented 8 years ago

Is there anything I can do to help troubleshoot this (log file, debug mode, ...) ?

acastaner commented 8 years ago

Just found another extension that crashes: Go (https://marketplace.visualstudio.com/items?itemName=lukehoban.Go)

As soon as I open a Go file I get the same error as with C#. Still no problem with reStructuredText or PowerShell extensions.

jrieken commented 8 years ago

All on windows 7? They all start external processes to do the real work, maybe something on your machine isn't happy with that. Can you open the Omnisharp Log (View > Output > Omnisharp) and also the console from dev tools? (F1 > Developer Tool)

acastaner commented 8 years ago

Yes, all on the Windows 7 Pro PC.

The Output > Extensions output window shows nothing (it's just empty). The console shows the same errors as the window:

Extension host terminated unexpectedly. Please reload the window to recover. Extension host terminated unexpectedly. Code: 3221225477 Signal: null Error from the extension host: channel closed

jrieken commented 8 years ago

Nothing in Output > Omnisharp Log?

acastaner commented 8 years ago

Unfortunately no. The Output window only lists "Extensions", "Git" and "Tasks" : http://imgur.com/WyczdxC

I definitively have C# installed though: http://imgur.com/YDglUif

jrieken commented 8 years ago

That is very interesting... It seems to crash already when loading the extension. Do you see C# in the little language indicator at the bottom (that makes sure the static part of the extension gets loaded)? Also can you check if there a the Restart OmniSharp command in the F1 palette, iff so restart without having a file open and just run the command.

acastaner commented 8 years ago

Yes, I do have the Restart OmniSharp command. When I executed it I got these messages:

Error from the extension host: channel closed
Extension host terminated unexpectedly. Please reload the window to recover.
Error from the extension host: write EPIPE

I don't see C# in the language indicator at the bottom, but I do notice that the status bar says Downloading and configuring .NET Core Debugger and that seems to be what gets stuck.

jrieken commented 8 years ago

@DustinCampbell Is there a way to start omnisharp without it downloading the debugger etc?

DustinCampbell commented 8 years ago

Not that I know of. However, note that the Go extension is reported as crashing as well. Perhaps that will be easier to investigate?

jrieken commented 8 years ago

yeah, there must be something wrong when spawning processes, tho not on all. @joaomoreno you mentioned something today during the standup

joaomoreno commented 8 years ago

That issue ended up being Code's shared process failure to launch with a broken VSCODE_NLS_CONFIG value: #6375. Doesn't seem related.

@acastaner could you try launching the processes that the extensions launch, but manually from a command line?

acastaner commented 8 years ago

What process would that be? Because dotnet is already installed works just fine from the command line so I'm not sure what VSCode actually calls and with which parameters.

jrieken commented 8 years ago

@DustinCampbell can help you out with that.

DustinCampbell commented 8 years ago

The extension attempts to download and untar OmniSharp to ~/.vscode/extensions/ms-vscode.csharp.0.3.7/.omnisharp and launches the OmniSharp process from there.

For the debugger, the extension generates a project.json file in ~/.vscode/extensions/ms-vscode.csharp.0.3.7/coreclr-debug. It then launches "dotnet restore" with the generated project.json to acquire the debugger bits.

However, the extension creates two OutputChannels during this installation process: one for the debugger ("coreclr-debug") and one for OmniSharp ("OmniSharp Log"). I find it strange that neither of these appear as @acastaner reported above. This happens very early in the extension activation. I also find it strange that the Go extension fails as well.

@jrieken, @joaomoreno, any ideas?

joaomoreno commented 8 years ago

Just noticed something from a comment above:

Extension host terminated unexpectedly. Code: 3221225477 Signal: null

electron/electron#3570 says that 3221225477 is a really ugly crash, as in segfault or access violation.

acastaner commented 8 years ago

I was thinking about this yesterday and remembered that I have two context menu icons for VSCode. One is from one of the early build that I guess didn't uninstall/unregister correctly (same with Atom, as you can see) :

http://imgur.com/zr5uJlP

Could it be that OmniSharp (and Go) is somehow trying to use that one, but since it doesn't exist anymore it fails? Probably not that but just a thought.

acastaner commented 8 years ago

Just upgraded to version 1.3.1 and still have the issue. I see that it's flagged with "needs more info." Any suggestion on what information is needed to help find the root cause?

E: I just noticed that the error message is slightly different in 1.3.1. Now I get this:

https://imgur.com/dBfvlKi

Error from the extension host: write EPIPE

jrieken commented 7 years ago

Closing this because we never understood this issue and because time has passed and we believe things are better now

MrYakobo commented 7 years ago

Throwing in my two cents here. I recently relabeled my drive that I work in from G: to E: which then made Code throw this "Extension host terminated unexpectedly" at me while editing some JS. It seems like Code (or some extension I have) is dependant on the labeling of drives.