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

Linux "dotnet run" fails with Win32Exception when launching at low process priority #5372

Closed
Foritus opened this issue May 24, 2020 · 5 comments
Labels

Comments

@Foritus
Copy link

Foritus commented May 24, 2020

Hello, this has recently regressed and caused my build system to fall over. We manually invoke dotnet build with nice -n20 ionice -c3 to ensure the machine remains responsive during a large build, but this now causes msbuild to crash in recent builds.

It looks like the bug is here: https://github.com/microsoft/msbuild/blob/236f48ecb51e413c13a16d55b6712df4d0a3ca9f/src/MSBuild/XMake.cs#L630
MSBuild needs to store the process' current priority instead of assuming it is running at "Normal".

Commit that introduced the regression: b111470#diff-3099880c51224257bef6905bc2dfbf3d

Steps to reproduce

dotnet new webapi
nice -n20 dotnet build

Observe crash.
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.ComponentModel.Win32Exception (13): Permission denied
at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Unhandled exception. System.ComponentModel.Win32Exception (13): Permission denied
at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)

Expected behavior

MSBuild doesn't crash.

Actual behavior

It crashes.

Environment data

dotnet --version
3.1.300

OS info:
Ubuntu Server 18 lts

@Foritus
Copy link
Author

Foritus commented May 24, 2020

I made a small change on a fork to see what the fix might look like: master...Foritus:master It would be simpler to change the "lowPriority" priority to "Idle" but I assume someone cared enough to use BelowNormal rather than Idle, so I preserved the behaviour.

@cbricart
Copy link

related: #5365

@rainersigwald
Copy link
Member

Thanks for the report! @Forgind, can you look at this? I think it might be more complete than #5365.

@rainersigwald
Copy link
Member

Duplicate of #5365

@Forgind
Copy link
Member

Forgind commented May 27, 2020

It would be simpler to change the "lowPriority" priority to "Idle" but I assume someone cared enough to use BelowNormal rather than Idle, so I preserved the behaviour.

I went with @bgianfo's design. In his words:

The process priority documentation https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netcore-3.1
seems to state that idle would end up starving the build of any real scheduler time slice if you are actually using your machine at all.
The idea was to give UI/interactive processes priority, so they remain responsive, but to still make progress in the background.

@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants