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

CSC hangs for 20 seconds when run with /shared argument on .NET SDK 8.0.200 #72180

Closed
joncham opened this issue Feb 16, 2024 · 11 comments
Closed
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@joncham
Copy link

joncham commented Feb 16, 2024

Describe the bug

The used of the csc /shared argument causes a 20 second delay/hang.

This seems to be a regression from 8.0.1.

To Reproduce

Using the 8.0.200 SDK

Measure-Command { .\dotnet.exe sdk\8.0.200\Roslyn\bincore\csc.dll /shared /? }  

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 20
Milliseconds      : 104
Ticks             : 201047737
TotalDays         : 0.000232694140046296
TotalHours        : 0.00558465936111111
TotalMinutes      : 0.335079561666667
TotalSeconds      : 20.1047737
TotalMilliseconds : 20104.7737


Measure-Command { .\dotnet.exe sdk\8.0.200\Roslyn\bincore\csc.dll /? }        

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 75
Ticks             : 751743
TotalDays         : 8.70072916666667E-07
TotalHours        : 2.088175E-05
TotalMinutes      : 0.001252905
TotalSeconds      : 0.0751743
TotalMilliseconds : 75.1743

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
.\dotnet.exe --info
.NET SDK:
 Version:           8.0.200
 Commit:            438cab6a9d
 Workload version:  8.0.200-manifests.cdf2cc8e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win-x64
 Base Path:   <redacted>\sdk\8.0.200\

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.2
  Architecture: x64
  Commit:       1381d5ebd2
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Feb 16, 2024
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@xoofx
Copy link
Member

xoofx commented Feb 20, 2024

Wondering if it belongs here or it's more for https://github.com/dotnet/roslyn, @jaredpar maybe you might know?

@jaredpar jaredpar transferred this issue from dotnet/sdk Feb 20, 2024
@jaredpar
Copy link
Member

Do you have a perf trace of this anywhere, or a dump when it hangs?

I'm not able to reproduce this locally. Tried a few variations of the commands.

@joncham
Copy link
Author

joncham commented Mar 4, 2024

@jaredpar do you want file attached here or is there some place to upload or send?

@joncham
Copy link
Author

joncham commented Mar 4, 2024

Debugging a bit locally, and I see the call here to CreateNamedPipeClient repeatedly fail and return Interop.Errors.ERROR_FILE_NOT_FOUND

@jaredpar
Copy link
Member

jaredpar commented Mar 4, 2024

Do you see what the value of _normalizedPipePath is at that location? For that to happen and having the 20 second timeout I would expect that the compiler server is actually failing to start in this scenario. Under the hood /shared is starting the server if it doesn't exist yet and it will end up waiting ~20 seconds for it to establish a named pipe. Guessing that is what's happening here.

@joncham
Copy link
Author

joncham commented Mar 5, 2024

The value of _normalizedPipePath is \\.\pipe\A3e62qkUmq+JJ8FWJ7uk5QQGtvwg_ahrh712xdcr_sc

@joncham
Copy link
Author

joncham commented Mar 5, 2024

After debugging a bit more, it seems like the issue is that we are using a zip/binary deployment of the SDK. We do not have 8.0.200 installed on the machine. The server launch uses the system path to dotnet.exe. So, when I run:

<path to sdk>\dotnet.exe <path to sdk>\sdk\8.0.200\Roslyn\bincore\csc.dll /shared /?   

It tries to run the following to launch the server:

"C:\Program Files\dotnet\dotnet.exe" exec "<path to sdk>\dotnet-8-sdk-win-x64\sdk\8.0.200\Roslyn\bincore\VBCSCompiler.dll" "-pipename:A3e62qkUmq+JJ8FWJ7uk5QQGtvwg_ahrh712xdcr_sc"

And this fails with error:

You must install or update .NET to run this application.
App: <path to sdk>\dotnet-8-sdk-win-x64\sdk\8.0.200\Roslyn\bincore\VBCSCompiler.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '8.0.2' (x64)
.NET location: C:\Program Files\dotnet\

The following frameworks were found:
  5.0.17 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  6.0.26 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  7.0.15 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  8.0.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Learn more:
https://aka.ms/dotnet/app-launch-failed

@jaredpar
Copy link
Member

jaredpar commented Mar 5, 2024

Unfortunately I'm not sure what we can do here. There isn't really an API for "get me the path to the host process" so not sure how to re-use the existing dotnet.exe / dotnet here to launch the server.

Been discussed in dotnet/runtime before but don't think we came to a resolution.

dotnet/runtime#88754

@agocke, @ericstj

@xoofx
Copy link
Member

xoofx commented Mar 5, 2024

Unfortunately I'm not sure what we can do here. There isn't really an API for "get me the path to the host process" so not sure how to re-use the existing dotnet.exe / dotnet here to launch the server.

So, as a workaround, does that mean that in order to setup a dotnet environment correctly with a custom dotnet SDK path, we need to both set DOTNET_HOST_PATH and PATH accordingly? (As it looks like Roslyn is probing first for DOTNET_HOST_PATH here)

@jjonescz
Copy link
Member

jjonescz commented Mar 5, 2024

we need to both set DOTNET_HOST_PATH and PATH accordingly

Yes, but you can also just set PATH accordingly (pointing to the custom SDK first) and DOTNET_HOST_PATH can be unset, I think.

@jaredpar jaredpar closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

4 participants