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

Programs are not cleaned up under some circumstances #136

Open
raxod502 opened this issue Nov 2, 2021 · 0 comments
Open

Programs are not cleaned up under some circumstances #136

raxod502 opened this issue Nov 2, 2021 · 0 comments

Comments

@raxod502
Copy link
Member

raxod502 commented Nov 2, 2021

Suppose I write this program in C++:

#include <iostream>

int main() {
  while (1) {
    std::cout << "yes" << std::endl;
  }
}

Then if I run it, say, four times using the Run button, I'll end up with this output from within the container (via docker exec):

root@cpp:~/src# pstree -a
my_init -u /usr/local/sbin/my_init --quiet --skip-runit -- bash -c...
  └─bash -c...
      ├─bash -c...
      │   └─bash -c...
      │       └─runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c...
      │           └─riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               ├─bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               │   └─main
      │               └─(riju-pty)
      ├─bash -c...
      │   └─bash -c...
      │       └─runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c...
      │           └─riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               ├─bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               │   └─main
      │               └─(riju-pty)
      ├─bash -c...
      │   └─bash -c...
      │       └─runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c...
      │           └─riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               ├─bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               │   └─main
      │               └─(riju-pty)
      ├─bash -c...
      │   └─bash -c...
      │       └─runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c...
      │           └─riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               ├─bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │               │   └─main
      │               └─riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      │                   └─riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./main )
      └─bash -c...
          └─sleep 1
r

And this:

root@cpp:~/src# ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0  15204 11020 ?        Ss   03:46   0:00 /usr/bin/python3 -u /usr/local/sbin/my_init --quiet --skip-runit -- bash -c #!/usr/bin/env bash  set -euo pipefail  umask 0
root           7  0.3  0.0   6532  4016 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         210  0.0  0.0   6016   952 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         212  0.0  0.0   6016  2116 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         214  0.0  0.0   8232  4016 ?        S    03:46   0:00 runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c set -euo pipefail; stty cols 80 rows 24; ( c
riju         215  0.0  0.0   2376   768 ?        S    03:46   0:00 /var/cache/riju/share/riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextr
riju         216  0.0  0.0   6148  3648 pts/0    Ss+  03:46   0:00 bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./mai
riju         218  0.5  0.0      0     0 ?        Z    03:46   0:00 [riju-pty] <defunct>
riju         231  0.7  0.0   6108  1648 pts/0    S+   03:46   0:00 ./main
root         338  0.0  0.0   6016   956 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         340  0.0  0.0   6016  2116 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         341  0.0  0.0   8232  3912 ?        S    03:46   0:00 runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c set -euo pipefail; stty cols 80 rows 24; ( c
riju         343  0.0  0.0   2376   692 ?        S    03:46   0:00 /var/cache/riju/share/riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextr
riju         344  0.0  0.0   6148  3632 pts/1    Ss+  03:46   0:00 bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./mai
riju         345  0.1  0.0      0     0 ?        Z    03:46   0:00 [riju-pty] <defunct>
riju         359  0.1  0.0   6108  1720 pts/1    S+   03:46   0:00 ./main
root         448  0.0  0.0   6016   956 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         450  0.0  0.0   6016  2116 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         454  0.0  0.0   8232  3672 ?        S    03:46   0:00 runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c set -euo pipefail; stty cols 80 rows 24; ( c
riju         459  0.0  0.0   2376   696 ?        S    03:46   0:00 /var/cache/riju/share/riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextr
riju         462  0.0  0.0   6148  3728 pts/2    Ss+  03:46   0:00 bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./mai
riju         463  0.1  0.0      0     0 ?        Z    03:46   0:00 [riju-pty] <defunct>
riju         477  0.2  0.0   6108  1708 pts/2    S+   03:46   0:00 ./main
root         567  0.0  0.0   6016   956 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         568  0.0  0.0   6016  2244 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         569  0.0  0.0   6016  2116 ?        S    03:46   0:00 bash -c #!/usr/bin/env bash  set -euo pipefail  umask 077  while read -t2 -r cmdline; do     cmd=(${cmdline})     for (( i=
root         572  0.0  0.0   8232  3968 ?        S    03:46   0:00 runuser -u riju -- bash -c exec /var/cache/riju/share/riju-pty "$@" -- bash -c set -euo pipefail; stty cols 80 rows 24; ( c
riju         580  0.0  0.0   2376   756 ?        S    03:46   0:00 /var/cache/riju/share/riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextr
riju         581  0.0  0.0   6148  3668 pts/3    Ss+  03:46   0:00 bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextra main.cpp -o main ) && ( ./mai
riju         582 23.7  0.0   2376    84 ?        R    03:46   0:16 /var/cache/riju/share/riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextr
riju         583  0.0  0.0   2376    84 ?        S    03:46   0:00 /var/cache/riju/share/riju-pty bash -c set -euo pipefail; stty cols 80 rows 24; ( clang++ -std=c++17 -pedantic -Wall -Wextr
riju         588 33.8  0.0   6108  1772 pts/3    R+   03:47   0:22 ./main
root         652  0.1  0.0   6364  4160 pts/4    Ss   03:47   0:00 bash
root        1205  0.0  0.0   4428   768 ?        S    03:48   0:00 sleep 1
root        1214  0.0  0.0   8732  3384 pts/4    R+   03:48   0:00 ps aux

So the user code is not being terminated! That's very bad since it causes CPU to be eaten up forever, until the container is shut down entirely. I found this out after getting paged for sustained CPU usage on Riju.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant