fish-shell / fish-shell/fish-shell

find a way to make `psub --fifo` safe from deadlock

Open
#1,040 30 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
34.2k
Forks
2.4k
Avg merge
2d 8h
Merged PRs (30d)
13

Description

There are actually a couple of bugs here.

The easy one is [here](http://github.com/fish-shell/fish-shell/blob/master/share/functions/psub.fish#L56) — `use_fifo` is missing a sigil and is therefore a string comparison, causing `psub` to always act as `psub -f`.

Unfortunately, it's not as simple as fixing that typo as doing so will cause a non-interruptable hang under certain circumstances. I believe it occurs when the pipe buffer is exceeded? But I'm not sure how to actually determine the pipe buffer in fish. Maybe forking another process is needed? Or... something.

Anyway, here's a (hopefully) cross-platform [test case](http://gist.github.com/g-nix/6972484/raw/rhino) (about 1.5MiB and requires Java, uses openssl to decode base64). It's a standalone wrapper for [rhino](http://github.com/mozilla/rhino). There's a big hunk of base64 in the middle of it, but the script is just:
`java -jar (echo 'BIGHUNKOFBASE64' | openssl base64 -d | psub)`

Contributor guide

Open the contributing guide

Research direction

Start with share/functions/psub.fish, inspect the use_fifo check, and reproduce the hang with the linked Rhino wrapper or the 1.5 MiB Java command. Done means the typo is corrected and the --fifo path handles the large input without an uninterruptible deadlock across the supported platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.