bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

5.0 regression: Script stuck when waiting in trap


From: mwnx
Subject: 5.0 regression: Script stuck when waiting in trap
Date: Sun, 2 Jun 2019 13:55:10 +0200
User-agent: Mutt/1.9.4 (2018-02-28)

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-Dl674z/bash-5.0=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security
uname output: Linux cbb62a3d8393 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 
18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 3
Release Status: release

Description:
        Since bash 5.0, a subshell can get stuck (wait forever) in
        what looks like a pretty specific set of circumstances,
        namely when combining a group command or a function call
        with process substitution and attempting to `wait` for said
        group command or function from within a trap.

        I ran a git bisect to pinpoint when exactly the regression
        was introduced and it looks like it happened in [1].

        [1] d233b485 (tag: bash-5.0) bash-5.0 distribution sources and 
documentation

Repeat-By:
        $ cat <<'EOF' | bash
        (
            trap 'wait' EXIT
            { sleep 2; } > >(cat)
        ) &
        sleep 1
        kill $!
        wait
        EOF
        <ctrl-C after a few seconds of waiting>
        # The process is actually still alive, even after ctrl-C...
        $ pstree -p
        sh(1)-+-bash(6)---pstree(321)
              `-bash(316)---bash(318)---cat(320)

        Replacing `{ sleep 2; }` above with `f() { sleep 2; }; f`
        gives the same result. On the other hand, replacing it with
        plain `sleep 2`, or `(sleep 2)` eliminates the problem.

--
mwnx
GPG: AEC9 554B 07BD F60D 75A3  AF6A 44E8 E4D4 0312 C726
     ipfs.io/ipfs/QmV4tMgNmqewgcPgX4ktAbrA9jHeiM2DhEFSB4BKxwj75c



reply via email to

[Prev in Thread] Current Thread [Next in Thread]