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

Process.WaitForExit() deadlock when running multiple processes on linux with .net7 #80563

Closed
kirnosenko opened this issue Jan 12, 2023 · 6 comments

Comments

@kirnosenko
Copy link

Description

Running multiple processes concurrently using System.Diagnostics.Process causes a deadlock on linux with .net7. I checked this, but I believe it is something else.

Reproduction Steps

A simple example to reproduce deadlock is here.

Expected behavior

no deadlock

Actual behavior

deadlock

Regression?

No response

Known Workarounds

No response

Configuration

.net7 on x64 alpine linux container

Other information

I tested it in different environments:
.net6 + windows = fine
.net6 + linux = fine
.net7 + windows = fine
.net7 + linux = deadlock

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 12, 2023
@ghost
Copy link

ghost commented Jan 12, 2023

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Running multiple processes concurrently using System.Diagnostics.Process causes a deadlock on linux with .net7. I checked this, but I believe it is something else.

Reproduction Steps

A simple example to reproduce deadlock is here.

Expected behavior

no deadlock

Actual behavior

deadlock

Regression?

No response

Known Workarounds

No response

Configuration

.net7 on x64 alpine linux container

Other information

I tested it in different environments:
.net6 + windows = fine
.net6 + linux = fine
.net7 + windows = fine
.net7 + linux = deadlock

Author: kirnosenko
Assignees: -
Labels:

area-System.Diagnostics.Process

Milestone: -

@adamsitnik
Copy link
Member

@tmds is there any chance you could take a look?

@tmds
Copy link
Member

tmds commented Jan 14, 2023

@kirnosenko you've only observed this issue in a container, right?

You can work around it by changing the entrypoint to something like:

ENTRYPOINT ["/bin/sh", "-c", "dotnet <your_assembly>.dll"]

#79817 fixes this and is backported for an upcoming 7.0 patch release.

@kirnosenko
Copy link
Author

@tmds yes I run it in container, unfortunately your suggestion makes no any difference, still has a deadlock.

@tmds
Copy link
Member

tmds commented Jan 17, 2023

unfortunately your suggestion makes no any difference, still has a deadlock.

Ah, I thought it would be enough to make the .NET process have another pid than 1, but that's not true.

If you add the --init flag to the docker run command (which adds an init process as pid 1), the deadlock disappears.

#79817 fixes this issue.

@adamsitnik
Copy link
Member

@tmds thank you for your help!

@adamsitnik adamsitnik closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jan 18, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants