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

[BUG] C# + C# Dev Kit does not activate and throws exception #7065

Closed
arunchndr opened this issue Apr 24, 2024 · 3 comments
Closed

[BUG] C# + C# Dev Kit does not activate and throws exception #7065

arunchndr opened this issue Apr 24, 2024 · 3 comments

Comments

@arunchndr
Copy link
Member

From vscode-dotnettools created by jubalaaronmurrian: microsoft/vscode-dotnettools#1066

Describe the Issue

When the C# Dev Kit extension is installed in an dotnet:8.0 jammy devcontainer hosted on a Apple M1 Max, the following exception is thrown.

Installing Razor Telemetry Version = 7.0.0-preview.24168.4...
Platform: linux, x86_64, name=ubuntu, version=22.04

Downloading package 'Razor Language Server Telemetry (Linux / x64)' (9343 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'Razor Language Server Telemetry (Linux / x64)'

Finished

Using dotnet configured on PATH
Dotnet path: /usr/share/dotnet/dotnet
Activating C# + C# Dev Kit...
waiting for named pipe information from server...
Language server process exited with null
[Error - 9:39:07 AM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Timeout. Client cound not connect to server via named pipe
at q. (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.23.15-linux-x64/dist/extension.js:2:1292059)
at Generator.next ()
at s (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.23.15-linux-x64/dist/extension.js:2:1281535)

Steps To Reproduce

Environment:

Host: Apple M1 Max

DevContainer: Platform: linux, x86_64, name=ubuntu, version=22.04

Config:

devcontainer.json

{ "name": "Azure Functions (.NET)", "dockerComposeFile": "docker-compose.yml", "service": "app", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "forwardPorts": [ 7071, 10000, 10001, 10002 ], "otherPortsAttributes": { "onAutoForward": "ignore" }, "features": { "ghcr.io/devcontainers/features/azure-cli:1": {}, "ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools:1": {} }, "customizations": { "vscode": { // Bug fix on Mac: https://github.com/microsoft/vscode-remote-release/issues/8169 "settings": { "extensions.verifySignature": false }, "extensions": [ "ms-azuretools.vscode-azurefunctions", "ms-dotnettools.csdevkit" ] } } }

docker-compose.yml

`version: "3"

services:
app:
build:
context: .
dockerfile: Dockerfile
platform: linux/amd64
volumes:
- ../..:/workspaces:cached
command: sleep infinity
network_mode: service:azurite

azurite:
image: mcr.microsoft.com/azure-storage/azurite
restart: unless-stopped`

Dockerfile

FROM mcr.microsoft.com/devcontainers/dotnet:8.0-jammy

Error:

Installing Razor Telemetry Version = 7.0.0-preview.24168.4...
Platform: linux, x86_64, name=ubuntu, version=22.04

Downloading package 'Razor Language Server Telemetry (Linux / x64)' (9343 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'Razor Language Server Telemetry (Linux / x64)'

Finished

Using dotnet configured on PATH
Dotnet path: /usr/share/dotnet/dotnet
Activating C# + C# Dev Kit...
waiting for named pipe information from server...
Language server process exited with null
[Error - 9:39:07 AM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Timeout. Client cound not connect to server via named pipe
at q. (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.23.15-linux-x64/dist/extension.js:2:1292059)
at Generator.next ()
at s (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.23.15-linux-x64/dist/extension.js:2:1281535)

Expected Behavior

C# + C# Dev Kit activates without error.

Environment Information

OS: macOS Sonoma
Visual Studio Code Version:
Version: 1.88.1 (Universal)
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:42:52.765Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.4.0
C# Dev Kit Version:
1.4.29

@dibarbet
Copy link
Member

dibarbet commented May 8, 2024

Both the C# extension and C# devkit appear to be crashing with various errors. Possibly due to running a linux x64 container on an arm64 machine.

There's no consistent place that the crash happens, I've seen any of the following errors:

[stderr] Unhandled exception: [stderr] Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "Microsoft.VisualStudio.Composition.PassthroughMetadataViewProvider".
---> System.NullReferenceException: Object reference not set to an instance of an object.
   at InvokeStub_PassthroughMetadataViewProvider..ctor(Object, Object, IntPtr*)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[stderr] assertion failed [block != nullptr]: BasicBlock requested for unrecognized address
(BuilderBase.h:550 block_for_offset)
Language server process exited with null
Using preinstalled .NET runtime at "/usr/share/dotnet/dotnet"
.NET server STDERR: Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
 
.NET server STDERR:    at System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].FindValue(System.__Canon)
   at System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryGetValue(System.__Canon, System.__Canon ByRef)

@arunchndr arunchndr added this to the May2024 milestone May 8, 2024
@dibarbet
Copy link
Member

dibarbet commented May 8, 2024

@jubalaaronmurrian a workaround that seems to work on my end is to add the line

ENV DOTNET_EnableWriteXorExecute=0

in my dockerfile.

I don't think there is anything we can do on the extension side to resolve this. As far as I understand it, it looks the runtime isn't able to detect that its running under rosetta emulation inside the container, and so cannot disable an unsupported feature.

See dotnet/runtime#94909
dotnet/runtime#80733
dotnet/runtime#97828

Closing as external.

@dibarbet dibarbet closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2024
@jubalaaronmurrian
Copy link

@dibarbet
Thank You, the workaround worked for me also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants