microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.26k stars 812 forks source link

Terminal emulator gives blank screen when executing HTOP or SCREEN #7660

Closed AriESQ closed 2 years ago

AriESQ commented 2 years ago

Version

Microsoft 10 Enterprise LTSC 1809 [Version 10.0.17763.2268]

WSL Version

Kernel Version

Linux 4.4.0-17763-Microsoft x86_64

Distro Version

Ubuntu 18.04 LTS

Other Software

openssh.exe cmd.exe ssh htop screen ncurses

Repro Steps

1) Open an WSL instance, which drops you to a functioning command prompt. Execute HTOP, screen goes blank. Press Q to exit HTOP, and you will see a portion of HTOP at the top of your screen, confirming it was running.

2) ssh into a remote linux instance from the WSL environment. Execute SCREEN or HTOP, you will receive a blank screen, but keyboard input is still active.

3) open CMD, run openssh.exe to ssh into a linux machine. Execute Screen or HTOP, you will receive a blank screen, but keyboard input is still active.

4) While attempting to attach strace logs, I ran man strace and found that even man is broken, giving a blank screen. type man strace and you will have a blank screen, exit with q and you will have some scrollbck of the man page.

Because this behavior is shared between WSL and CMD.exe in terminal mode, I believe that the problem may lie in the underlying windows terminal emulation.

KB5006744 appears to be the breaking update. If I uninstall this update the problem goes away, if I re-install it the problem comes back.

I suspect the problem is that when the remote system or PTY grabs control of the terminal, such as by issuing a window resize, ASCII control code, or the like the window terminal emulator is misinterpreting it and painting a black screen.

I have troubleshooted by removing .bashrc and .profile custom PS1 prompt configurations that might be transmitting ANSI color codes. I have switched users to a bare root /bin/sh shell. I have tested on different local and remote linux installations.

The terminal in vs-code is not affected by this issue, and third-party terminal emulator ConEmu is also not affected by this flaw.

I may have traced things to default pager less. Or, less has the same problems experienced by htop and screen. Overriding the default pager via man -P more allows man to execute. So less is affected but more is not. top is unaffected but htop is.

I have attached strace but nothing jumps out at me as the culprit.

wsl.exe --status produces no output, however the binary has a modified date of 2020-03-10. I believe I have an older version of WSL1, perhaps installed via github? I mention this extensively because my version of windows is not supported by Windows Terminal.

Expected Behavior

The terminal application should not go to a blank screen when executing programs such as HTOP (Ncurses) or SCREEN (spawns a PTY).

Actual Behavior

When executing commands such as HTOP or Screen, the terminal emulator paints a black screen.

Diagnostic Logs

No response

craigloewen-msft commented 2 years ago

@AriESQ thanks for giving the write up here that this issue might not be totally fixed. I'll follow up with the Windows console team to see if the behaviour you mentioned is a bug. I'll keep this issue open for now!

AriESQ commented 2 years ago

@craigloewen-msft I don't expect ya'll to try to replicate my exact bug report. My thinking was that you could run this behavior by the patch author, and see if it rings a bell like "oh yeah, I could see an off-by-one error during window resizing."

Am I being overly pedantic with this bug fix? Maybe. Is there some industrial control system somewhere integrating Macro Recorder to programmatically interact with a WSL shell window... Possibly? That's the only reason I am raising the potential incorrectness of the provided solution. Or some other hacked-together, yet vital usage...

I'm about ready for this ticket to be closed. I would have put more effort into reviewing this solution, but the opaque Microsoft update process has turned me off. If I had the original breaking patch, and the updated patch; I could know what to test. This is sort of frustrating, because it seems that this info exists in MS-Terminal and the newly open-sourced ConHost repo. 🤷‍♂️

craigloewen-msft commented 2 years ago

Since the original issue (The screen going blank when executing HTOP or SCREEN) is fixed, I'll be closing out this issue. @AriESQ for the extra issues you mentioned I'd recommend reaching out to the Terminal team by filing an issue at https://github.com/microsoft/terminal (As you've already identified). Thank you all!

AriESQ commented 2 years ago

Is anyone experiencing an issue where the mouse does not interact with the WSL terminal screen? I can not select text. Also when I paste into the terminal with shift-ins I do not get content I get control characters: 2~

Powershell and CMD.exe work with mouse selection as normal.

If no-one else is experiencing this, I just don't have the energy to track down Microsoft's broken stuff anymore and I won't be following up.

@craigloewen-msft Were there any changes recently that might have touched this functionality?

I think my most recent updates are KB5013868 KB501394

Same config as in original post.

foobird13 commented 2 years ago

I do see the control characters when pressing Shift-INS (same with Ctrl-INS). Although, that's not a key-combo I've ever used before, I just stick with Ctrl-Shift-C/V for copying/pasting (as long as the option is enabled in the console settings).

I don't have any issue with mouse interaction. Selecting text works just fine for me, as well as pasting with right-click.

Last update was KB5012647 (May updates haven't been installed yet).

AriESQ commented 2 years ago

Thank you @foobird13 If I don't see acknowledgement of this issue, I'll assume it is something unique to my setup that is broken. (Always a possibility).

StnVsl commented 2 years ago

ctrl+v and shift+ins don't work in WSL terminal, but ctrl+shift+v does if enabled in settings. Mouse selection, right-click copy/paste and ctrl-c/ctrl-ins work as usual. KB5013868/KB5013941 didn't change these things on Server 2019.

djpbessems commented 1 year ago

Since the original issue (The screen going blank when executing HTOP or SCREEN) is fixed, I'll be closing out this issue. @AriESQ for the extra issues you mentioned I'd recommend reaching out to the Terminal team by filing an issue at https://github.com/microsoft/terminal (As you've already identified). Thank you all!

What?? You're closing this when it's still an issue for running openssh within powershell and possibly many other combinations?