[GHC] #11695: On GHCi prompt the arrow (movement) keys create strange character sequences

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences --------------------------------------+--------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- Fire up `GHCi` and sit on the arrow down (or left) keys. This is what I get after constantly pressing for some time: {{{ $ ghci GHCi, version 8.1.20160202: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/ggreif/.ghci Prelude> OBOBOBBOBOBOBOBOBOBOBCOCCOCOCCOCCOC <interactive>:1:1: error: Data constructor not in scope: OBOBOBBOBOBOBOBOBOBOBCOCCOCOCCOCCOC }}} When such a strange letter appears, there is also a blinking of the terminal. It is not happening on Windows. I have seen it on RHEL5 and RHEL6. Pretty annoying, especially when you want to quickly navigate in the repl. This is probably a `haskeline` bug, but I am coming here to see whether others suffer from it too, i.e. is it reproducible for elseone? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by heisenbug): FWIW, I found this in a reddit thread, so it seems to be reproducible: https://www.reddit.com/r/haskell/comments/2jmdcg/ghci_uses_readline/clds4pm -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by bgamari): Hmmm, I tried holding the down arrow key for 30 seconds or so but was unable to reproduce this. That being said, it's possible this is due to a different typematic rate. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by heisenbug): I did some experiments: doing it in an `ssh` session (to the very same machine) from a Windows laptop does not trigger the bug. I should say that the RHEL box is a server, `$DISPLAY` is a `vnc` session on different a login box. So there is more IO triggered on the `ghci` machine than one would assume. I did the same thing (wandering around in a block of "mmmmmm"), with `python` repl. No problems. So it mist be a `ghci` thing: {{{ $ ghci GHCi, version 7.11.20150407: http://www.haskell.org/ghc/ :? for help *Main> mmmmmmmmmmmmmmmmmmmmmmmmmmmmODmmmmmmOCmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmCmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmCmmmmmmmmmmmmmmmmmmmmmOODDmmmOCmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm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mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm }}}
Maybe this is some improper handling of `EINTR` (or such) ? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by judahj): By any chance are you using tmux or a similar program? If so, check out the instructions here (your symptoms sound similar): https://github.com/judah/haskeline/wiki/UsingTmux Otherwise, can you give a little more information about your setup? - What is the value of $TERM - What terminal program (e.g. xterm) you're using - To try to figure out exactly what's confusing ghci: can you explain more what "$DISPLAY is a vnc session on a different box" means? I'm not familiar with that kind of setup. Which machine are you actually typing text into, and how is that text being relayed to the server that's actually running ghci? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

By any chance are you using tmux or a similar program? If so, check out
#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by heisenbug): Replying to [comment:4 judahj]: the instructions here (your symptoms sound similar):
No `tmux`. My terminal is a simple `xterm`. There are 3 computers involved: * a windows laptop visualizing a VNC session (by RealVNC) * a linux machine (say, `hostA`) running `vncserver` * another linux server on which I am `slogin`-ed named `hostB`. `hostB` runs `ghci` and has `export DISPLAY=hostA:2` in effect. So all X visuals are being painted into the `vncserver` session.
Otherwise, can you give a little more information about your setup? - What is the value of $TERM - What terminal program (e.g. xterm) you're using - To try to figure out exactly what's confusing ghci: can you explain
more what "$DISPLAY is a vnc session on a different box" means? I'm not familiar with that kind of setup. Which machine are you actually typing text into, and how is that text being relayed to the server that's actually running ghci? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by judahj): Thanks for the details. To clarify, what machine are you slogin'd *from* into hostB, is it your laptop or hostA? If your laptop, what Windows program are you using to do the connection? (More details: I'm trying to reason about the chain of events from you pressing your key to it getting received by gghci as the character sequence "\ESC[A" (or similar). The problem is that gghci (really, haskeline) expects to read those characters in a single block, but in your setup they're arriving separately for some reason.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by heisenbug): Replying to [comment:6 judahj]:
Thanks for the details. To clarify, what machine are you slogin'd *from* into hostB, is it your laptop or hostA? If your laptop, what Windows program are you using to do the connection?
It is not the laptop. The keystroke/mousing/visualization chain is: {{{ laptop <--vnc--> hostA <--ssh--> hostB }}}
(More details: I'm trying to reason about the chain of events from you
pressing your key to it getting received by gghci as the character sequence "\ESC[A" (or similar). The problem is that ghci (really, haskeline) expects to read those characters in a single block, but in your setup they're arriving separately for some reason.) So `ghci` actually utilizes `haskeline`? I heard something to the contrary before. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by heisenbug): @judahj, is there any way for me to help to track this one down? Maybe with printf-style debugging? It is a bit embarrassing when demoing GHCi and this happens out of nothing... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by judahj): Let's try this. Can you please download the file Read.hs from: https://gist.github.com/judah/5c5ad518bb43d235efba4fa8f1e9953a And run (in the same terminal/environment that you have the ghci problem): {{{ ghc Read.hs ./Read }}} Then press some letter keys and some arrow keys, and let me know what the output is? For example, on my terminal: {{{ $ ./Prompt "a" "s" "d" "\ESC[D" "\ESC[B" "\ESC[A" }}} The last three lines are from when I pressed arrow keys. Do you see them split into separate lines (e.g. "\ESC", "[" and "D")? If so, that's the problem we should try to solve. Does the same behavior of Read.hs occur on laptop<-vnc->hostA, or only on laptop<->hostA<->hostB? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by thomie): * status: new => infoneeded Comment: ping @heisenbug. See comment:9. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Let's try this. Can you please download the file Read.hs from: https://gist.github.com/judah/5c5ad518bb43d235efba4fa8f1e9953a
And run (in the same terminal/environment that you have the ghci
{{{ ghc Read.hs ./Read }}}
Then press some letter keys and some arrow keys, and let me know what
For example, on my terminal: {{{ $ ./Prompt "a" "s" "d" "\ESC[D" "\ESC[B" "\ESC[A" }}} The last three lines are from when I pressed arrow keys. Do you see
#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by heisenbug): Replying to [comment:9 judahj]: problem): the output is? them split into separate lines (e.g. "\ESC", "[" and "D")? If so, that's the problem we should try to solve. Does the same behavior of Read.hs occur on laptop<-vnc->hostA, or only on laptop<->hostA<->hostB? I see stuff like this: {{{ "\ESC[C" "\ESC[" "C" "\ESC[C" "\ESC[C" "\ESC[C" "\ESC[C" "\ESC[C\ESC[C" "\ESC[C" "\ESC[C" }}} Ha, this looks funny: {{{ "\ESC[B" "\ESC[B" "\ESC[B\ESC[B\ESC[B\ESC[B\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B\ESC[B\ESC[B" "\ESC[B" "\ESC[B\ESC[B" "\ESC[B\ESC[B" "\ESC[B" "\ESC[B" }}} Above sequences happen when via VNC. Let me test putty... ... completely dull. The strings look like this: {{{ "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" "\ESC[B" }}} Hope this helps!! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by heisenbug): Going via PC <-> VNC <-> hostA I sometimes see {{{ "\ESC[B" "\ESC[" "B" "\ESC[B" "\ESC" "[B" "\ESC[B" }}} The escape sequences seem to break up at strange places. Now the weird part. When going PC <-> hostA <-> hostB and opening an `xterm` there, and feeding `./Read` from there with keystrokes, I sometimes see duplicated escape sequences, but never the broken-up ones. Maybe this is just luck, but I really tried (even with considerable load on hostB). So maybe the X-Windows system is not the culprit at all. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11695: On GHCi prompt the arrow (movement) keys create strange character sequences ---------------------------------+-------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by heisenbug): * status: infoneeded => new Comment: Looking at my previous comments it appears that the syscall `read` will (sometimes) break up `ESC` sequences (when coming through some `ssh` tunnel?), and `haskeline` chokes on bachelor `ESC`s instead of `read`ing on and combining stuff. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11695#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC