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

'error: process ID out of range' when running an container #402

Closed
winks opened this issue Mar 21, 2022 · 2 comments
Closed

'error: process ID out of range' when running an container #402

winks opened this issue Mar 21, 2022 · 2 comments

Comments

@winks
Copy link
Contributor

winks commented Mar 21, 2022

I am trying to install erlang 24.3.2 in a redhat/ubi8 container and kerl errors out in the SHELL_SUFFIX check.

Removing intermediate container 0f8337abdd79
 ---> 335f5f14b7fc
Step 8/10 : RUN 	cd /tmp && ./kerl install 24.3.2 /opt/erlang/24.3.2
 ---> Running in 9d2d6f3f2a02
Installing Erlang/OTP 24.3.2 (24.3.2) in /opt/erlang/24.3.2...
error: process ID out of range

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1)

This is the Dockerfile I use at the moment (just started, that's why there are many layers)

# docker build -t foo .
FROM redhat/ubi8

RUN \
    yum install -y \
        autoconf \
        automake \
        gcc \
        git \
        make \
        ncurses-devel \
        openssl-devel

RUN \
    cd /tmp && \
    curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl && \
    chmod a+x kerl && \
    ./kerl build 24.3.2

RUN \
    yum install -y \
        unixODBC \
        unixODBC-devel

RUN \
    yum install -y \
        procps

RUN \
    cd /tmp && ./kerl install 24.3.2 /opt/erlang/24.3.2

This is how it looks interactively:

[root@c071e2ea1c6a /]# echo $$
62
[root@c071e2ea1c6a /]# export PID=$$; echo $PID
62
[root@c071e2ea1c6a /]# export PARENT_PID=$(ps -p $PID -o ppid=)
[root@c071e2ea1c6a /]# echo $PARENT_PID 
1
[root@c071e2ea1c6a /]# export PARENT_CMD=$(ps -p $PARENT_PID -o ucomm | tail -n 1)
[root@c071e2ea1c6a /]# echo $PARENT_CMD
bash

And this is what seems to happen:

[root@c071e2ea1c6a /]# export PID=$$; echo $PID
1
[root@c071e2ea1c6a /]# export PARENT_PID=$(ps -p $PID -o ppid=)
[root@c071e2ea1c6a /]# echo $PARENT_PID
0
[root@c071e2ea1c6a /]# export PARENT_CMD=$(ps -p $PARENT_PID -o ucomm | tail -n 1)
error: process ID out of range

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).

So I guess a missing check for PID=0 around this code would help:

        PARENT_PID=$(ps -p $PID -o ppid=) || exit 1
        # shellcheck disable=SC2086
        PARENT_CMD=$(ps -p $PARENT_PID -o ucomm | tail -n 1)
@jadeallenx
Copy link
Collaborator

Any further updates here? I will close this in about a week otherwise.

winks added a commit to winks/kerl that referenced this issue Nov 30, 2022
Add a check that looking up the parent PID of process 0 doesn't fail
@winks
Copy link
Contributor Author

winks commented Nov 30, 2022

Could still repro on master, thus the PR.

jadeallenx pushed a commit that referenced this issue Nov 30, 2022
Add a check that looking up the parent PID of process 0 doesn't fail
@winks winks closed this as completed Dec 1, 2022
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

2 participants