You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
After IO buffer is overrun, IO buffering is broken for future commands #5267
When the io buffer boundary is reached, the shell can be left unusable:
mqudsi@Blitzkrieg /m/d/r/fish> fg
/usr/local/share/fish/config.fish (line 279): Too much data emitted by command substitution so it was discarded
builtin fg (__fish_expand_pid_args $argv)
^
in function “fg”
called on standard input
Obviously, $argv is empty here and wouldn't have returned any data, let alone > 10MB.
To reproduce,
rubish.fish:
function foo1
for i in (seq 1 20)
cat /usr/share/dict/words
endend# Entire list of packages is too long to be used efficiently in a `complete` subcommand.# Search it for matches instead.function foo2
foo1 | string match -re -- ^(commandline-ct) #| head -n 50endcomplete-c rubbish -xa'(foo2)'
changed the title [-]After IO buffer is overrun, execution of future functions breaks[/-][+]After IO buffer is overrun, command substitution remains broken[/+]on Oct 19, 2018
changed the title [-]After IO buffer is overrun, command substitution remains broken[/-][+]After IO buffer is overrun, io buffering is broken for future commands[/+]on Oct 19, 2018
I'm pretty sure this was caused by 4197420, which never shipped in any release.
Sure, yeah.
More specifically, the "read too much" flag on the buffer is probably never reset.
Also, since we now have something that actually outputs 10MiB.... should we increase the limit?
I mean that entire thing came about because somebody noticed that reading from (IIRC) /dev/zero would "hang" fish and be generally unhelpful. So it just needs to be large enough that it's "hang detection", not something to discourage you from using the shell. So 100MiB or even 1GiB would probably be alright on most systems (obviously if you ran this on a raspberry pi with 256MiB of RAM and no swap the latter won't really work).
If we're over that the OS won't accept the arguments anyway. On my system getconf ARG_MAX returns 2097152, which is 2MiB.
No, the problem is that IO buffering is not only used for command substitution but also where it shouldn't be used such as piping output from a function's stdout to another function or process' stdin.
If you look at the example you'll note that there's no command substitution (apart from (commandline -ct), that is) going on. It's all stdout buffering.
IMHO this is fish's biggest job-related failure (way worse than the keepalive process), all function/block output is buffered when all of it should be using anonymous pipes connected directly to the read end instead. Moreover, the IO buffer isn't really a "buffer" in the traditional sense in that it's written to then read from (such as the OS' own pipe buffer) but rather a write-only buffer that becomes available for reading only after the write is completely finished, i.e. it must buffer the entire content.
Oh, I completely missed that, I was just focusing on the function definition. I'm pretty sure function output is buffered even without command substitution, but I think this bug (shell unusable) only affects command substitution.
I just ran into this working on the yarn completions again. It's definitely not fixed.
mqudsi@Blitzkrieg /m/d/r/fish> fg
Send job 1, “nvim share/completions/yarn.fish” to foreground
Job 1, 'nvim share/completions/yarn.fish' has stopped
mqudsi@Blitzkrieg /m/d/r/fish> fg
/usr/local/share/fish/config.fish (line 267): Too much data emitted by command substitution so it was discarded
builtin fg (__fish_expand_pid_args $argv)
^
in function “fg”
called on standard input
mqudsi@Blitzkrieg /m/d/r/fish> exit
There are still jobs active:
PID Command
26038 nvim share/completions/yarn.fish
A second attempt to exit will terminate them.
Use 'disown PID' to remove jobs from the list without terminating them.
It’s a recent master build but I know the test as documented here was fixed since I confirmed as much at the time. But the issue can be triggered differently.
This worked (it's an even simpler test than the original one):
mqudsi@Blitzkrieg /m/d/D/CPSA Board>function foo
bar (all-the-package-names)
end
mqudsi@Blitzkrieg /m/d/D/CPSA Board>function bar
end
mqudsi@Blitzkrieg /m/d/D/CPSA Board> foo
fish: Too much data emitted by command substitution so it was discarded
bar (all-the-package-names)
^infunction “foo”
called on standard input
mqudsi@Blitzkrieg /m/d/D/CPSA Board>fg
/usr/local/share/fish/config.fish (line 267): Too much data emitted by command substitution so it was discarded
builtinfg (__fish_expand_pid_args $argv)
^infunction “fg”
called on standard input
In addition, I'm going to increase the read limit to 100MiB. That still might not blow up your little Raspi, and you could possibly pass it in multiple passes. I don't think fish is used on smaller machines, so we don't need to optimize for those.
Activity
[-]After IO buffer is overrun, execution of future functions breaks[/-][+]After IO buffer is overrun, command substitution remains broken[/+][-]After IO buffer is overrun, command substitution remains broken[/-][+]After IO buffer is overrun, io buffering is broken for future commands[/+]mqudsi commentedon Oct 20, 2018
@faho: With regards to milestone, etc: I'm pretty sure this was caused by 4197420, which never shipped in any release.
Before that, there was no limit imposed on the command substitution size, so I don't think the shell could have reached this state.
faho commentedon Oct 20, 2018
Sure, yeah.
More specifically, the "read too much" flag on the buffer is probably never reset.
Also, since we now have something that actually outputs 10MiB.... should we increase the limit?
I mean that entire thing came about because somebody noticed that reading from (IIRC) /dev/zero would "hang" fish and be generally unhelpful. So it just needs to be large enough that it's "hang detection", not something to discourage you from using the shell. So 100MiB or even 1GiB would probably be alright on most systems (obviously if you ran this on a raspberry pi with 256MiB of RAM and no swap the latter won't really work).
faho commentedon Oct 20, 2018
Oh, wait, there actually is an underlying limit: ARG_MAX.
If we're over that the OS won't accept the arguments anyway. On my system
getconf ARG_MAXreturns 2097152, which is 2MiB.So that 10MiB won't work anyway.
mqudsi commentedon Oct 20, 2018
No, the problem is that IO buffering is not only used for command substitution but also where it shouldn't be used such as piping output from a function's stdout to another function or process' stdin.
If you look at the example you'll note that there's no command substitution (apart from
(commandline -ct), that is) going on. It's all stdout buffering.IMHO this is fish's biggest job-related failure (way worse than the keepalive process), all function/block output is buffered when all of it should be using anonymous pipes connected directly to the read end instead. Moreover, the IO buffer isn't really a "buffer" in the traditional sense in that it's written to then read from (such as the OS' own pipe buffer) but rather a write-only buffer that becomes available for reading only after the write is completely finished, i.e. it must buffer the entire content.
faho commentedon Oct 20, 2018
The
(foo2)inis a command substitution.
faho commentedon Oct 20, 2018
I can only confirm this with
rubbish <TAB>, but notrubbish a<TAB>, and if I replace(foo2)with(foo2 | string match -re ^a), it also works.So it really does seem like it's the command substitution buffer being used for a command substitution.
mqudsi commentedon Oct 20, 2018
Oh, I completely missed that, I was just focusing on the function definition. I'm pretty sure function output is buffered even without command substitution, but I think this bug (shell unusable) only affects command substitution.
faho commentedon Oct 20, 2018
Yup - #1396.
6 remaining items
Update yarn completions
io: Explicitly reset discard flag
Update yarn completions
mqudsi commentedon Jan 11, 2019
I just ran into this working on the
yarncompletions again. It's definitely not fixed.faho commentedon Jan 11, 2019
@mqudsi: This works for me. Please confirm your $version.
mqudsi commentedon Jan 11, 2019
It’s a recent master build but I know the test as documented here was fixed since I confirmed as much at the time. But the issue can be triggered differently.
faho commentedon Jan 13, 2019
@mqudsi: Any idea how? What did you do differently?
mqudsi commentedon Jan 13, 2019
This worked (it's an even simpler test than the original one):
faho commentedon May 29, 2019
Okay, this works for me with 29c627.
In addition, I'm going to increase the read limit to 100MiB. That still might not blow up your little Raspi, and you could possibly pass it in multiple passes. I don't think fish is used on smaller machines, so we don't need to optimize for those.
Increase default read limit to 100MiB