This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 355
Intermittent False EOF or panic when run under screen
#408
Labels
Comments
This was referenced Feb 16, 2022
Wow, awesome job tracking this down, and thank you for the fix! 🎉 |
abayer
added a commit
to abayer/cli
that referenced
this issue
Jun 28, 2022
I was having trouble debugging some tests I was working on refactoring, and eventually realized this was due to AlecAivazis/survey#408, which was fixed in survey v2.3.3. This also ends up upgrading hinshun/vt10x, getting rid of the `NewVT10xTerminal` function we'd been calling in a few places, so I band-aided that by adding an equivalent function in `test/helper/helpers.go`. Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
4 tasks
abayer
added a commit
to abayer/cli
that referenced
this issue
Jun 28, 2022
I was having trouble debugging some tests I was working on refactoring, and eventually realized this was due to AlecAivazis/survey#408, which was fixed in survey v2.3.3. This also ends up upgrading hinshun/vt10x, getting rid of the `NewVT10xTerminal` function we'd been calling in a few places, so I band-aided that by adding an equivalent function in `test/helper/helpers.go`. Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
tekton-robot
pushed a commit
to tektoncd/cli
that referenced
this issue
Jun 29, 2022
I was having trouble debugging some tests I was working on refactoring, and eventually realized this was due to AlecAivazis/survey#408, which was fixed in survey v2.3.3. This also ends up upgrading hinshun/vt10x, getting rid of the `NewVT10xTerminal` function we'd been calling in a few places, so I band-aided that by adding an equivalent function in `test/helper/helpers.go`. Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What operating system and terminal are you using?
screen --version
:Screen version 4.08.00 (GNU) 05-Feb-20
gnome-terminal --version
:# GNOME Terminal 3.38.3 using VTE 0.62.3 +BIDI +GNUTLS +ICU +SYSTEMD
An example that showcases the bug.
https://github.com/mgabeler-lee-6rs/survey-screen-eof-demo
What did you expect to see?
What did you see instead?
This is a bit on and off for whether it reproduces, but given a
screen
session that is "doing it", it becomes 100% reproducible in producing one of the failure modes, though which failure happens seems to be a bit variable run to run.The demo app linked above is just a trivial call to
AskOne
with aConfirm
, but it seems that pretty much any Ask will do it. This spun out of problems from multiple users with thegh
CLI: cli/cli#4739Failure mode 1: panic
This looks superficially similar to #394, but I'm unsure if it is really the same.
Failure mode 2: TTY garbage:
This is a much more common failure mode
Note that the "gobbledygook" is inserted into my terminal buffer.
Attempted Analysis:
Based on the "TTY garbage" mode, and from attaching a debugger to the demo app, it appears that one or more of the terminal control commands being sent is producing unexpected responses that are treated as user input. Running it under
strace -r -v -f
unfortunately seems to heisenbug it and produce a third failure mode where it gets the false EOF, but no TTY garbage. In this case, the onlyread
that shows in strace is like so:Which ... does look like an EOF. FWIW, the preceding
TCSETS
was:(full strace: trace.txt)
Going back to stepping through the debugger, it looks like the "TTY garbage" is coming from the terminal responding to the DSR escape sequence sent during
cursor.Cursor.Location()
, and I think it may be happening because the second call in this sequence, inrunereader.go
, is returning an error that is ignored:However, for whatever reason, with the debugger attached, it seems to be usually failing on the first one instead, which produces the "panic" failure mode (I think) if it ends up seeing the actual DSR response as user input, or as the EOF if that somehow doesn't happen in time to prevent it getting an EOF error when it gets here in
runereader.go
:Trying to trace down where some of the EOFs are coming from, I see the EOF seeming to come from this bit in stdlib's
bufio.go
:This brought me back to the
TCSETS
call, with itsVMIN
andVTIME
values of 0. It definitely doesn't seem like the code is expecting these settings, and is instead expecting the terminal i/o to still be in blocking i/o mode, even when having cleared canonical mode (ref: https://man7.org/linux/man-pages/man3/tcflow.3.html#:~:text=MIN%20%3D%3D%200%2C%20TIME%20%3D%3D%200%20(polling%20read)).On a working terminal, I get the
TCGETS
/TCSETS
calls having (among the other flags),c_cc[VMIN]=1, c_cc[VTIME]=0
.Which finally tells me how I can submit a PR to fix this :D I don't know why my
screen
sessions sometimes haveVMIN=0
, but since this application is configuring the terminal, it should configure it to the way it needs instead of assuming someone else will have :)The text was updated successfully, but these errors were encountered: