dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 670 forks source link

Port 55555 used for "waitForDebugger" is unavailable since macOS 11 #5121

Open heshuimu opened 2 years ago

heshuimu commented 2 years ago

Issue Description

When trying to debug OmniSharp using the omnisharp.waitForDebugger config, OmniSharp would fail to wait for debugger and stop immediately.

When the config is enabled, Mono is set to launch the debugger server on port 55555, but since macOS 11 this port seemed to be been pre-occupied by the system, thus the launch would fail.

https://github.com/OmniSharp/omnisharp-vscode/blob/65799d34f09d561bc3b80c00566a6acd957d9fd9/src/omnisharp/launcher.ts#L416

➜  ~ nc -l 55555           
nc: Address already in use

As a proof of concept, I searched for the string in the extension JS file and changed the port to 55556, which OmniSharp is able to wait for debugger upon restarting VS Code.

Steps to Reproduce

Using latest VS Code, enable omnisharp.waitForDebugger and restart OmniSharp.

Expected Behavior

OmniSharp server will wait for debugger to attach

Actual Behavior

The process terminates with debugger-agent: Unable to listen on 3

Logs

OmniSharp log

Starting OmniSharp server at 3/21/2022, 11:30:07 AM
    Target: /Users/Yuki/PlasticSCM/Polytone-NextGenClient/Polytone-NextGenClient.sln

OmniSharp server started with Mono 6.12.0 (/Library/Frameworks/Mono.framework/Versions/Current).
    Path: /Users/Yuki/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/omnisharp/OmniSharp.exe
    PID: 10220

debugger-agent: Unable to listen on 3

C# log

Empty

Environment information

VSCode version: 1.65.2 C# Extension: 1.24.1

Mono Information OmniSharp using global mono :6.12.0
Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.201 Commit: ef40e6aa06 Runtime Environment: OS Name: Mac OS X OS Version: 12.3 OS Platform: Darwin RID: osx.12-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.201/ Host (useful for support): Version: 6.0.3 Commit: c24d9a9c91 .NET SDKs installed: 6.0.201 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |better-cpp-syntax|jeff-hykin|1.15.13| |cpptools|ms-vscode|1.8.4| |cpptools-extension-pack|ms-vscode|1.1.0| |cpptools-themes|ms-vscode|1.0.0| |csharp|ms-dotnettools|1.24.1| |doxdocgen|cschlosser|1.4.0| |errorlens|usernamehw|3.4.2| |jupyter|ms-toolsai|2022.2.1030672458| |jupyter-keymap|ms-toolsai|1.0.0| |jupyter-renderers|ms-toolsai|1.0.6| |mono-debug|ms-vscode|0.16.2| |python|ms-python|2022.2.1924087327| |shaderlabvscode|amlovey|1.2.4| |subtitles-editor|pepri|1.1.6| |vscode-antlr4|mike-lischke|2.2.4| |vscode-clang|mitaki28|0.2.4| |vscode-icons|vscode-icons-team|11.10.0| |vscode-pylance|ms-python|2022.3.2|;
nohwnd commented 2 years ago

@heshuimu Would you prefer this to be a setting? Or should we just hardcode a new port? Please consider creating a PR either way :)

heshuimu commented 2 years ago

@heshuimu Would you prefer this to be a setting? Or should we just hardcode a new port? Please consider creating a PR either way :)

I'm debating myself on this one. I may go for the settings route, just because this solves the issue once and for all.