term: fix eof hangup when pasting multiple of the libuv read buffer#911
Merged
term: fix eof hangup when pasting multiple of the libuv read buffer#911
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There exists a longstanding bug that shows up when you paste text into the dojo with a length of any multiple of 123 characters. This is most easily reproduced by running
(crip (reap 123 'a'))in the dojo and copy pasting the output back into the terminal.The root cause turns out to be a misconfigured terminal. We specify a
VMINof 0 for ourtermiosstruct, which results in the following behavior.Consider what happens when libuv tries to read exactly 123 characters with a buffer that's also 123 character large. The first
readcall will return all the characters but does not indicate that there aren't more characters to come. A secondreadcall will thus be made returning 0.Libuv of course has no idea that our terminal is this wonky so it reasonably assumes that the zero returned by
readisEOFand dutifully stops the read handle, which explains why hang if we no-op in response toEOFwithout this fix:https://github.com/libuv/libuv/blob/8fb9cb919489a48880680a56efecff6a7dfb4504/src/unix/stream.c#L1110-L1111
https://github.com/libuv/libuv/blob/8fb9cb919489a48880680a56efecff6a7dfb4504/src/unix/stream.c#L932-L939