Skip to content

Process substitution hangs out on Bash 4.4 #4

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

Closed
esigma5 opened this issue Apr 18, 2017 · 16 comments
Closed

Process substitution hangs out on Bash 4.4 #4

esigma5 opened this issue Apr 18, 2017 · 16 comments

Comments

@esigma5
Copy link

esigma5 commented Apr 18, 2017

Hello! Not sure whether this is a docker-bash issue or an alpine issue, so excuse me if this is not the right place.

When using Process substiution in the standard way, terminal just hangs out. It seems Bash enters some infinite loop or something, because the process starts consuming too much cpu.

emasoero@emasoero-X555LAB:~$ docker run -ti bash:4.4
bash-4.4# cat <(ls)
bin
dev
etc
home
lib
media
mnt
proc
root
run
sbin
srv
sys
tmp
usr
var
^C^C

I manually installed bash 4.4 on an ubuntu docker image (16.04) and it works fine

@tianon
Copy link
Owner

tianon commented Apr 21, 2017

Oh wow, this is a bizarre one! 👍

I'm guessing this is an issue with the way we compile Bash, but it's hard to say for certain since Alpine upstream doesn't have Bash 4.4 yet (https://pkgs.alpinelinux.org/packages?name=bash); it could very well be some kind of odd musl-related issue. Definitely needs more digging to figure out what's going on. 😞

@tianon
Copy link
Owner

tianon commented Apr 21, 2017

It appears to only exhibit when we're interactive, too:

$ docker run -it --rm bash:4.4 -c 'cat <(ls)'
bin
dev
etc
home
lib
media
mnt
proc
root
run
sbin
srv
sys
tmp
usr
var
$ 

Edit: nothing to do with TTY though!

$ docker run -i --rm bash:4.4 <<<'cat <(ls)'
bin
dev
etc
home
lib
media
mnt
proc
root
run
sbin
srv
sys
tmp
usr
var

(hangs)

@tianon
Copy link
Owner

tianon commented Dec 4, 2017

Turns out this is likely an Alpine-related issue!

See gliderlabs/docker-alpine#363 and https://bugs.alpinelinux.org/issues/8236.

@unode
Copy link

unode commented Dec 6, 2017

See also https://bugs.alpinelinux.org/issues/8098.
The bug was closed since the packaging issue was solved but the underlying problem remained.

Downgrading and compiling bash from source works though and is currently the workaround used here.

@jumanjiman
Copy link

Bizarrely, this issue does not occur on https://labs.play-with-docker.com/

IOW, on play-with-docker start an alpine:edge container and attempt to reproduce.
None of the reproducers hang when using play-with-docker.

However, the reproducers do hang in my local dev environments.

This seems to rule out process substitution by itself.
Perhaps it's some combination of tty handling and process substitution.

@ncopa
Copy link

ncopa commented Dec 6, 2017

@unode See also https://bugs.alpinelinux.org/issues/8098.
The bug was closed since the packaging issue was solved but the underlying problem remained.

I think it was closed after fixing so the patches was actually applied.
alpinelinux/aports@cec73ee

I am not able to reproduce it on my work desktop, nor in lxc containers, so the issue was probably resolved with some of the upstream bash patches.

But I can still reproduce it in docker, so this is weird.

Another workaround may be to not use bash at all with configure script:

    CONFIG_SHELL=/bin/ash ./configure ...

@ncopa
Copy link

ncopa commented Dec 6, 2017

I think we should report this upstream. This will be difficult to debug and code is non-trivial to follow and understand. I am not convinced the bug is in alpine or musl, even if the problem does not show on glibc distros. Could be some wrong assumptions regarding signal handling or similar.

@ncopa
Copy link

ncopa commented Dec 7, 2017

Turns out to be a bug in musl after all. A fix is on the way...
http://www.openwall.com/lists/musl/2017/12/07/7

@ncopa
Copy link

ncopa commented Dec 7, 2017

Actually its a bug in bash too. It can be reproduced with glibc too:

ulimit -u 9223372036854775807
bash -c 'sleep 1 & wait $!'

Will fix bash too while at it.

algitbot pushed a commit to alpinelinux/aports that referenced this issue Dec 7, 2017
@tianon
Copy link
Owner

tianon commented Dec 9, 2017

You're a hero, @ncopa ❤️

For the peanut gallery, this was fixed in Alpine's bash package in alpinelinux/aports@3239e62 (bash-4.4.12-r2) and filed upstream with Bash in https://lists.gnu.org/archive/html/bug-bash/2017-12/msg00025.html (and confirmed receipt by Chet in https://lists.gnu.org/archive/html/bug-bash/2017-12/msg00026.html).

I think while Chet figures out what he's going to do about this bug officially upstream, we should likely temporarily apply Alpine's patch for 4.4 (since 4.3 and below are unaffected).

@tianon tianon closed this as completed in 6305240 Dec 9, 2017
tianon added a commit to infosiftr/stackbrew that referenced this issue Dec 12, 2017
- `bash`: apply Alpine patch to 4.4 for process substitution hang (tianon/docker-bash#4)
- `golang`: add `alpine3.7` variant of 1.9 (docker-library/golang#192)
- `rabbitmq`: add 3.7, which includes a new configuration file format (docker-library/rabbitmq#197)
- `ruby`: remove `2.5-rc-alpine3.6` variant (superseded by `2.5-rc-alpine3.7`)
@ncopa
Copy link

ncopa commented Feb 7, 2018

looks like it does not solve it for 32 bit architectures. https://bugs.alpinelinux.org/issues/8447
I could reproduce it with i386/bash image. Should I open new ticket or do we want re-open this?

@tianon
Copy link
Owner

tianon commented Feb 7, 2018

I'll reopen, thanks 👍 ❤️

@tianon tianon reopened this Feb 7, 2018
@ncopa
Copy link

ncopa commented Feb 7, 2018

I followed up upstream with a new proposed patch, which I also pushed to alpine linux.

tianon added a commit that referenced this issue Jul 12, 2019
I've done some testing, and this is no longer required on Bash 5+!
@tianon
Copy link
Owner

tianon commented Jul 12, 2019

I've tried reproducing this (on 5.0 and 4.4) by removing the patch we're applying and it doesn't seem to be reproducible anymore (on any of Alpine 3.9, Alpine 3.10, amd64, i386). Was this fixed in one of the minor patches to Bash 4.4 perhaps?

@tianon
Copy link
Owner

tianon commented Jul 12, 2019

Looking through https://ftp.gnu.org/gnu/bash/bash-4.4-patches/, nothing after we first started experiencing this seems related at a glance. 😕

Is it possible a change in musl mitigated this too?

@tianon
Copy link
Owner

tianon commented Jul 12, 2019

Confirmed, I had to go all the way back to Alpine 3.6 in order to reproduce the original issue.

@tianon tianon closed this as completed in 3682e16 Jul 12, 2019
docker-library-bot added a commit to docker-library-bot/official-images that referenced this issue Jul 12, 2019
Changes:

- tianon/docker-bash@3682e16: Update to Alpine 3.10
- tianon/docker-bash@fe0fe8a: Add "devel" commit description to Dockerfile
- tianon/docker-bash@11b071d: Add "devel" variant from Chet's "devel" branch
- tianon/docker-bash@9282546: Remove workaround for tianon/docker-bash#4 on 5+
- tianon/docker-bash@af7a2fd: Update generated README
docker-library-bot added a commit to docker-library-bot/official-images that referenced this issue Jul 12, 2019
Changes:

- tianon/docker-bash@a9c27dc: Add aliases to "devel" like "devel-20190705" (based on Chet's commit message)
- tianon/docker-bash@3682e16: Update to Alpine 3.10
- tianon/docker-bash@fe0fe8a: Add "devel" commit description to Dockerfile
- tianon/docker-bash@11b071d: Add "devel" variant from Chet's "devel" branch
- tianon/docker-bash@9282546: Remove workaround for tianon/docker-bash#4 on 5+
- tianon/docker-bash@af7a2fd: Update generated README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants