csharp-language-server icon indicating copy to clipboard operation
csharp-language-server copied to clipboard

hangs when using .NET SDK Arm64 (Apple M1)

Open august-feng opened this issue 2 years ago • 8 comments

Hello! Possibly related to https://github.com/razzmatazz/csharp-language-server/issues/33.

I had to install the x64 distributions of the .NET SDK for things to work. It was weird because csharp-ls was not crashing when I ran it from the CLI, but it would hang in Emacs.

Once the x64 is installed, don't forget to reconfigure the DOTNET_ROOT environment variable to /usr/local/share/dotnet/x64 in Emacs.

august-feng avatar Jan 31 '23 21:01 august-feng

Hey. I am coding on M1 too, IIRC things should just work on latest (28.2+ish emacs)

What is your version of emacs, lsp client (lsp-mode or eglot?), distribution (doom/spacemacs/something else?)

Have you installed arm64 version of dotnet-core? Or both (x64+arm64?) Which version(s) of runtime/SDKs do you have installed?

(Sorry for replying this late)

razzmatazz avatar Feb 05 '23 15:02 razzmatazz

Hey, I'm running lsp-mode and spacemacs (emacs 28.2). I couldn't get it to work when I strictly only had the arm64 version (dotnet 6 and 7). I got it to work in the end by having only x64 distributions.

What dotnet distributions are you running?

august-feng avatar Feb 07 '23 22:02 august-feng

could you do a "dotnet stack report -p " on a hung server?

razzmatazz avatar Feb 08 '23 06:02 razzmatazz

personally i wqs using dotnet-7.0.1 but don't have access to the pc ATM. it was working with dotnet6 sdks on m1 too

razzmatazz avatar Feb 08 '23 07:02 razzmatazz

There's no dotnet-stack for the arm64 release on M1 :(

august-feng avatar Feb 09 '23 20:02 august-feng

There's no dotnet-stack for the arm64 release on M1 :(

are you sure? because it is working for me..

Bildschirm­foto 2023-02-10 um 07 00 46
bob@mbp ~ % dotnet stack --version
6.0.328102+ab657cc109f93e48d52f6b12cd7f136bb2d0b311

bob@mbp ~ % ps ax | grep -i CSharp
41868   ??  Ss     0:30.39 /Users/bob/src/csharp-language-server/src/CSharpLanguageServer/bin/Debug/net7.0/CSharpLanguageServer -s src/solution.sln
42144 s003  U+     0:00.00 grep -i CSharp

bob@mbp ~ % ps ax | grep -i CSharp
41868   ??  Ss     0:31.77 /Users/bob/src/csharp-language-server/src/CSharpLanguageServer/bin/Debug/net7.0/CSharpLanguageServer -s src/solution.sln
42245 s003  R+     0:00.00 grep -i CSharp
bob@mbp ~ % dotnet stack report -p41868
Thread (0x4C0D1B):
  [Native Frames]
  System.Private.CoreLib!System.Threading.ManualResetEventSlim.Wait(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.SpinThenBlockingWait(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.InternalWaitCore(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.Wait(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.WaitAnyCore(class System.Threading.Tasks.Task[],int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.WaitAny(class System.Threading.Tasks.Task[])
  Ionide.LanguageServerProtocol!Ionide.LanguageServerProtocol.Server.startWithSetup(class Microsoft.FSharp.Core.FSharpFunc`2<!!0,class Microsoft.FSharp.Collections.FSharpMap`2<class System.String,class System.Delegate>>,class System.IO.Stream,class System.IO.Stream,class Microsoft.FSharp.Core.FSharpFunc`2<class System.Tuple`2<class Microsoft.FSharp.Core.FSharpFunc`2<class System.String,class Microsoft.FSharp.Core.FSharpFunc`2<class System.Object,class Microsoft.FSharp.Control.FSharpAsync`1<value class Microsoft.FSharp.Core.FSharpResult`2<class Microsoft.FSharp.Core.Unit,class Error>>>>,class ClientRequestSender>,!!0>,class Microsoft.FSharp.Core.FSharpFunc`2<class StreamJsonRpc.IJsonRpcMessageHandler,class StreamJsonRpc.JsonRpc>)
  CSharpLanguageServer!CSharpLanguageServer.Server.startCore(class Options)
  CSharpLanguageServer!CSharpLanguageServer.Server.start(class Options)
  CSharpLanguageServer!CSharpLanguageServer.Program.entry(class System.String[])

Thread (0x4C0D2D):
  [Native Frames]
  System.Private.CoreLib!System.Threading.WaitHandle.WaitOneNoCheck(int32)
  System.Private.CoreLib!System.Threading.PortableThreadPool+GateThread.GateThreadStart()
(...)

razzmatazz avatar Feb 10 '23 05:02 razzmatazz

oh.. you need to install/update this tool manually, it is not bundled with .net core installation

bob@mbp ~ % dotnet tool install --global dotnet-stack

razzmatazz avatar Feb 10 '23 05:02 razzmatazz

Ah, I tried that actually and it was complaining I did not have the x64 architecture and the documentation doesn't include arm64 as a download option:

You must install .NET to run this application.

App: /Users/august.feng/.dotnet/tools/dotnet-stack
Architecture: x64
App host version: 7.0.2
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.13-x64&apphost_version=7.0.2

But, dotnet tool install --global dotnet-stack -a arm64 gets me an arm64 version! :)

The dump:

dotnet stack report -p  41682
Thread (0x187539):
  [Native Frames]
  System.Private.CoreLib!System.Threading.ManualResetEventSlim.Wait(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.SpinThenBlockingWait(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.InternalWaitCore(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.Wait(int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.WaitAnyCore(class System.Threading.Tasks.Task[],int32,value class System.Threading.CancellationToken)
  System.Private.CoreLib!System.Threading.Tasks.Task.WaitAny(class System.Threading.Tasks.Task[])
  Ionide.LanguageServerProtocol!Ionide.LanguageServerProtocol.Server.startWithSetup(class Microsoft.FSharp.Core.FSharpFunc`2<!!0,class Microsoft.FSharp.Collections.FSharpMap`2<class System.String,class System.Delegate>>,class System.IO.Stream,class System.IO.Stream,class Microsoft.FSharp.Core.FSharpFunc`2<class System.Tuple`2<class Microsoft.FSharp.Core.FSharpFunc`2<class System.String,class Microsoft.FSharp.Core.FSharpFunc`2<class System.Object,class Microsoft.FSharp.Control.FSharpAsync`1<value class Microsoft.FSharp.Core.FSharpResult`2<class Microsoft.FSharp.Core.Unit,class Error>>>>,class ClientRequestSender>,!!0>,class Microsoft.FSharp.Core.FSharpFunc`2<class StreamJsonRpc.IJsonRpcMessageHandler,class StreamJsonRpc.JsonRpc>)
  CSharpLanguageServer!CSharpLanguageServer.Server.startCore(class Options)
  CSharpLanguageServer!CSharpLanguageServer.Program.entry(class System.String[])

Thread (0x18755C):
  [Native Frames]
  System.Private.CoreLib!System.Threading.WaitHandle.WaitOneNoCheck(int32)
  System.Private.CoreLib!System.Threading.PortableThreadPool+GateThread.GateThreadStart()
  System.Private.CoreLib!System.Threading.Thread.StartCallback()

Thread (0x18755F):
  [Native Frames]
  ?!?
  System.Console!Interop+Sys.Read(class System.Runtime.InteropServices.SafeHandle,unsigned int8*,int32)
  System.Console!System.ConsolePal.Read(class Microsoft.Win32.SafeHandles.SafeFileHandle,value class System.Span`1<unsigned int8>)
  System.Console!System.IO.ConsoleStream.Read(unsigned int8[],int32,int32)
  System.Private.CoreLib!System.IO.Stream+<>c.<BeginReadInternal>b__38_0(class System.Object)
  System.Private.CoreLib!System.Threading.Tasks.Task`1[System.Int32].InnerInvoke()
  System.Private.CoreLib!System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(class System.Threading.Thread,class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object)
  System.Private.CoreLib!System.Threading.Tasks.Task.ExecuteWithThreadLocal(class System.Threading.Tasks.Task&,class System.Threading.Thread)
  System.Private.CoreLib!System.Threading.ThreadPoolWorkQueue.Dispatch()
  System.Private.CoreLib!System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
  System.Private.CoreLib!System.Threading.Thread.StartCallback()

Thread (0x18756F):
  [Native Frames]
  ?!?
  System.Net.Sockets!System.Net.Sockets.SocketAsyncEngine.EventLoop()
  System.Private.CoreLib!System.Threading.Thread.StartCallback()

august-feng avatar Feb 10 '23 11:02 august-feng