WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Typing text in the bash: existing text is overwritten, new text is not inserted

Open jepster opened this issue 10 years ago • 37 comments

  • A brief description When I type text into the bash, the existing text is overwritten. The new text is not inserted.

  • Expected results If I type new text, it should not overwrite the existing one. Outside of the bash, the result is the expected one.

  • Your Windows build number 14393.0

  • Steps / All commands required to reproduce the error from a brand new installation Just an open bash.

jepster avatar Nov 01 '16 17:11 jepster

@jepster What PC are you using? More specifically, what graphics card (if any)?

Does this happen in cmd.exe or powershell? or is it only bash.exe?

Could you post a screenshot?

zadjii-msft avatar Nov 02 '16 22:11 zadjii-msft

I am having the same / similar issue.

Basically, lets say I want to re-run the last entered command in a bash shell, but tweak some item in the command string. I hit the up arrow on my keyboard to repeat the last command, I arrow key over to where I want to make the change.

Now when I use the delete key, it doesn't (visually) display the deleted characters being deleted. And it appears to overtype new characters on what is left there.

In actuality, it DOES change the text, as evidenced when pressing enter to submit the command, but its near impossible to actually do this reliably since the modification cannot be seen.

OS Name: Microsoft Windows 10 Pro OS Version: 10.0.14393 N/A Build 14393

I tried on multiple GPUs, didn't make a difference.

~~EDIT: I should add, this does NOT occur for me when opening a bash shell from within powershell, it only happens when opening the "native" "Bash Ubuntu on Windows" shortcut.~~

Edit2: Just happened in powershell after being open overnight.

dreamwraith avatar Nov 04 '16 05:11 dreamwraith

@zadjii-msft The described issue appeared in the "bash.exe". I've tried to use the "bash.exe" inside the PHPStorm IDE. But there I cannot use the arrow keys of my keyboard. I guess that this issue appears on all IntelliJ IDE's like Android Studio etc.

System Info Screenshots

Here is some info about my PC. It is in german, but I guess that you are able to understand the system info from the context. PC Info

Here is info about my graphics card: Graphics Card

Screencast Video of bash.exe with showing the Problem

I have recorded a screencast of the behavior. You can get to the video by the following URL: https://drive.google.com/file/d/0B5vmNAcUsVUgSWtBS2pNTmFISGc/view

How to reproduce this bug?

At the beginning, the text typing is ok. I have opened a file in VIM, edited it a bit. Then the behavior was still ok. Afterwards I was installing a program via "sudo apt install youtube-dl". Then I wanted to remove it from the system by "sudo apt purge youtube-dl". Afterwards the problem appeared. However - you can see this in my screencast - the issue disappeared after a while if typing.

What could this have to do with my graphics card? I doubt that the issue is related to the graphics card.

jepster avatar Nov 06 '16 12:11 jepster

Just posting to confirm the screencast video Jepster posted is the identical behavior I am experiencing. I am experiencing it on multiple systems of different configuration, including a Hyper-V Server hosted Win10 VM, indicating (to me) there is no GPU issues at all.

I also experience similar behavior in that it does not occur until after the bash shell has been open for some indeterminate amount of time.

It happens with the bash exe directly, with powershell launched bash, and with command prompt launched bash. It seems to be specific to the bash shell itself.

dreamwraith avatar Nov 07 '16 07:11 dreamwraith

@jepster @diabolicallyrandom Hey so we may have found a hint in figuring this out.

Does this happen specifically after using apt to install something? Or can this happen in a fresh conhost.exe instance without really doing all that much?

I believe there's some program somewhere in the stack that's emitting something to cause conhost to get in a bad state, if only occasionally.

zadjii-msft avatar Nov 18 '16 22:11 zadjii-msft

For my part, I have always done something prior to it occurring of course. I am typically using SSH to connect to my Ubuntu server, or my OpenWRT router. However I also had it occur after a session in which I used apt to install image magic and work with some files on my mounted windows drives.

If I can fine the time I will try and replicate the behavior without doing anything in the shell, because I swear I had that happen too.

Just to confirm, this happens on command prompt bash, PowerShell bash, and launching the bash shortcut directly. And it usually (although sometimes) doesn't happen while I'm actively using it, but often it's when I use it and walk away for some time and come back.

Would there be a way I could provide some kind of debug logging that might help?

dreamwraith avatar Nov 18 '16 23:11 dreamwraith

If you could help get a reliable repro, that'd be huge. This has proven to be wildly difficult to get a consistent repro from. Just now, I found that on a small enough window with a sufficiently large screen buffer, alternating sudo apt install nmap and sudo apt remove nmap can cause some input line corruption. However, there's a good chance I'll come back to my desk on Monday and it'll be gone


Just to confirm, this happens on command prompt bash, PowerShell bash, and launching the bash shortcut directly.

For the record, all of those are all the same bash.exe running in conhost.exe. If it happened in plain old cmd.exe (no bash involved), now that certainly would be a bigger issue, but seeing how it's only a bash issue we can probably assume that there's some VT sequence that's messing with the console.

zadjii-msft avatar Nov 18 '16 23:11 zadjii-msft

Guys, I was typing a lot in the bash and I had this buggy behavior after I have run some PHP command line application. Then - in the hope that this was the issue causer - I have run the app again. But the Bash was behaving correct. Could it be, that there is any issue with the memory of the bash? Because the problem was never appearing directly but only after a while of working in the Bash. That would also describe why this issue happens with "apt". Because "apt" creates a lot of output on installing any application. Well, this is only "guessing". Though a reasonable indicator.

jepster avatar Nov 19 '16 10:11 jepster

I'm consistently seeing this problem on 14965. Vim is also affected. Demo: https://www.youtube.com/watch?v=eDd9A8YJCH8

I do most of my work in Vim, this is pretty bad :(

carlpaten avatar Nov 21 '16 12:11 carlpaten

I have the same problem as @lilred SSH via bash on windows is almost unusable with that bug...

pszafer avatar Nov 21 '16 14:11 pszafer

I eventually was able to get a consistent repro on this bug, so I'm opening MSFT:9871791 to investigate further. This one's probably the highest priority bug ATM.

zadjii-msft avatar Nov 21 '16 17:11 zadjii-msft

I am glad to read that. Thanks for your quick feedback.

jepster avatar Nov 22 '16 06:11 jepster

@zadjii-msft: Any news regarding the bug? Where can we see the state of "MSFT:9871791"? I guess this is a Microsoft bug tracker which is hidden for the public.

jepster avatar Nov 23 '16 20:11 jepster

It is our internal tracking number. It's under investigation, but I've been out for the holidays, so nothing new to report.

From: Peter Majmeskumailto:[email protected] Sent: Wednesday, November 23, 2016 12:20 PM To: Microsoft/BashOnWindowsmailto:[email protected] Cc: Mike Griesemailto:[email protected]; Mentionmailto:[email protected] Subject: Re: [Microsoft/BashOnWindows] Typing text in the bash: existing text is overwritten, new text is not inserted (#1307)

@zadjii-msfthttps://github.com/zadjii-msft: Any news regarding the bug? Where can we see the state of "MSFT:9871791"? I guess this is a Microsoft bug tracker which is hidden for the public.

You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/BashOnWindows/issues/1307#issuecomment-262620841, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARgZ1q7iJ9r1LH3qwN1u1LVbwdWIryonks5rBJ_tgaJpZM4KmVS8.

zadjii-msft avatar Nov 28 '16 03:11 zadjii-msft

Any news? (:

jepster avatar Dec 04 '16 12:12 jepster

@jepster Nothing yet. I think I got it pinned down in the code, but I don't have a fix tested yet.

zadjii-msft avatar Dec 05 '16 19:12 zadjii-msft

So, breakdown of what's going on here:

apt install (NOT apt-get install) uses '\x1b[1;{{height-1}}r' to set the scrolling margins of the terminal to one less than the entire terminal while it's displaying output (including that neat little loading bar of theirs). They then use '\x1b[1;{{height}}r' to reset the margins back to the entire screen height, effectively removing them.

Typically, setting the scroll margins is only done inside the Alternate Buffer on a terminal, eg, within an application like vim, and not usually on the main buffer. Resetting the margins by setting to the entire terminal height is fine on the alt buffer, because it is exactly the size of the terminal window (it has no scrollback).

However, conhost doesn't really have a traditional "scrollback", and if you set the margins to the entire terminal on the main buffer in conhost, then they would stay there, even once you scrolled away. This could create scenarios where certain text manipulations would be clipped to the old scroll margins (which were no longer on the screen). This would cause visual artifacts in the output buffer, even though the bash input line still logically knew the correct data.

I've put the fix in code review today. Thanks for all the help on this one everyone, pinning this one down was particularly challenging.

zadjii-msft avatar Dec 05 '16 21:12 zadjii-msft

Thanks for your very detailed feedback! It's great that Linux gets better and better as a subsystem in Windows by your effort. Can you share with us how the process looks like, until we will receive your update on our Windows 10 systems? Do you have an idea how much time it will take more or less?

jepster avatar Dec 05 '16 22:12 jepster

@jepster Basically, the process for a pretty trivial fix like this is as follows:

  • it'll bounce around code review a bit (for such a small fix, this doesn't take too long)
  • it then gets checked in to our teams source branch.
  • It now needs about 3 weeks to get up to winmain. This time varies depending on how stable winmain is, or if our sister team's quality remains good, or hey, even a holiday break (like the one at the end of the month) can put this off by a week. 3 is what I've found to be the average. Sometimes all the pieces line up just wrong and this can be MUCH longer.
  • Once it's in winmain, it's usually the following week's insider build that has the actual fix in it. I believe it goes into the fast ring then, but I don't really know enough to know how long it takes to go from Fast -> Slow.
  • And it'll hit non-Insiders whenever the Creator's Update hits

zadjii-msft avatar Dec 05 '16 23:12 zadjii-msft

@zadjii-msft: Thanks for your quick reply. Sounds like a straight forward process.

I am an non-insider. Can you tell me, how much difference there is between the non-insider and the insider release?

jepster avatar Dec 05 '16 23:12 jepster