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

Process OOMKilled when piping a function to another function #9747

Closed
dangoncalves opened this issue Apr 23, 2023 · 2 comments
Closed

Process OOMKilled when piping a function to another function #9747

dangoncalves opened this issue Apr 23, 2023 · 2 comments

Comments

@dangoncalves
Copy link

> fish --version
fish, version 3.6.1
> uname -a
Linux phobos 6.2.11-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Apr 13 20:07:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
> echo $TERM
xterm-256color

This bug report was reproduced by preparing the following environment:

> sh -c 'env HOME=$(mktemp -d) fish'
> function my-sudo
      /usr/bin/sudo $argv
  end
> function my-ssh
      /usr/bin/ssh $argv
  end

Then you can run the following command

> echo $fish_pid > /home/daniel/fish.pid
> my-sudo btrfs send /where/is/my/btrfs/snapshot/ | my-ssh my.remote.host "sudo btrfs receive /where/my/btrfs/snapshot/should/go"

At this point, after a few times the fish process is killed by OOM Killer. You can verify this by running

> cat fish.pid
91088
> journalctl -b | grep (cat fish.pid)
avril 23 18:53:00 phobos kernel: [  91088]  1000 91088  5961718  2185304 23162880   690144           200 fish
avril 23 18:53:00 phobos kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/user@1000.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-f0dd0720-6615-489d-993f-c72e47ca5d85.scope,task=fish,pid=91088,uid=1000
avril 23 18:53:00 phobos kernel: Out of memory: Killed process 91088 (fish) total-vm:23846872kB, anon-rss:8737376kB, file-rss:3840kB, shmem-rss:0kB, UID:1000 pgtables:22620kB oom_score_adj:200

Worth noting that running a command that not use too much stdout, or running a command with just one function instead of two works as expected.
For example, the following commands are NOT killed by OOM Killer

> my-sudo echo "plop" | my-ssh my.remote.host "cat /dev/stdin"
> /usr/bin/sudo btrfs send /where/is/my/btrfs/snapshot/ | my-ssh my.remote.host "sudo btrfs receive /where/my/btrfs/snapshot/should/go"
> my-sudo btrfs send /where/is/my/btrfs/snapshot/ | /usr/bin/ssh my.remote.host "sudo btrfs receive /where/my/btrfs/snapshot/should/go"
@faho
Copy link
Member

faho commented Apr 23, 2023

Duplicate of #1396

@faho faho marked this as a duplicate of #1396 Apr 23, 2023
@faho faho closed this as completed Apr 23, 2023
@faho faho added the duplicate label Apr 23, 2023
@faho
Copy link
Member

faho commented Apr 23, 2023

Fish buffers the output of functions in some circumstances, like when it goes to another function (because it can't currently run functions concurrently).

So, what happened was simply that your function filled up all your ram.

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

No branches or pull requests

2 participants