Skip to content

Tests in panic=abort can hang if test spawns a subprocess #68936

Open
@tmandry

Description

@tmandry

If a test (running in a subprocess, because panic=abort) spawns a sub-subprocess which inherits its stdout or stderr handles, and the sub-subprocess does not exit when the test does, the test framework will hang. This is because wait_with_output waits for all stdio handles to be closed.

libtest runner         (waits for unit test stdio to close)
       |
       |  Stdio::piped
       |
unit test process      (exits, but stdio is now shared with subproc)
      ||
      ||  Stdio::inherit
      ||
"leaked" subprocess    (sticks around forever)

Some tests spawn subprocesses, and it can be hard (particularly with panic=abort) to ensure that they are all cleaned up when the test succeeds or fails. In these cases, it would be best not to hang. Hanging is unexpected, and hard to debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions