Skip to content

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

Closed as not planned

Description

@kirnosenko

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

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Jan 12, 2023
  2. adamsitnik commented on Jan 13, 2023

    @adamsitnik
    Member

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

  3. tmds commented on Jan 14, 2023

    @tmds
    Member

    @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.

  4. kirnosenko commented on Jan 14, 2023

    @kirnosenko
    Author

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

  5. tmds commented on Jan 17, 2023

    @tmds
    Member

    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.

  6. adamsitnik commented on Jan 18, 2023

    @adamsitnik
    Member

    @tmds thank you for your help!

  7. ghost removed
    untriagedNew issue has not been triaged by the area owner
    on Jan 18, 2023
  8. ghost locked as resolved and limited conversation to collaborators on Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions