terminal: Windows Terminal (Preview) crashes with wrapped text

❗ N.B. This issue has also been reported via Feedback Hub link https://aka.ms/AAa8g4n (video/screenshots have been uploaded; posted 2 months ago, but still no resolution)

Environment

Windows build number: 10.0.19042.0
Windows Terminal version: 1.5.3242.0

Any other software?
Windows Terminal version: 1.4.3243.0

Steps to reproduce

  1. Open new Windows Terminal tab or window (using Windows Powershell in this case)

  2. Paste a long text string WITHOUT pressing ENTER.

    For example, this string (H/T http://powershell-guru.com/): Get-ChildItem -Path C:\Demo -Filter *.cs | Rename-Item -NewName {[System.IO.Path]::ChangeExtension($_.Name, ".kt")}

    Any long string of ASCII characters should also reproduce issue: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-

    The text will soft wrap in a standard Windows Terminal configuration (12pt text)

  3. Press backspace and begin deleting the text.

Expected behavior

The cursor should move up a line. Windows Terminal should not crash.

Actual behavior

Windows Terminal crashes just before the cursor moves up a line, or in other words, just before the character where the text is wrapped.

NOTE: This only appears to happen when there is one tab open.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Apologies if this is unhelpful noise but just a super delighted partially blind customer here wanting to validate that this bug is actually fixed in the wild!

I can run ‘npm i -g gatsby-cli’ now without Windows Terminal silently crashing! THIS MADE MY MONTH! 😃 Hearty thanks to all concerned. If you ever find yourself in Boston please look me up there’s a beverage with your name on it 😃

In the meantime, though, we should really get rid of those damn FAIL_FAST tests. Or anyone that is in favour of retaining them, should volunteer to have the telemetry from the crash logs wired up to their desk with a high-voltage shock.

It’s my fault. If you want to shock my chair, you can. I realize, like many things, this was a mistake in hindsight.

In the meantime, though, we should really get rid of those damn FAIL_FAST tests. Or anyone that is in favour of retaining them, should volunteer to have the telemetry from the crash logs wired up to their desk with a high-voltage shock.

@feoh thanks for the kind words! That really made the team’s day 😄

Thank you all for your hard work on this issue. It’s a real quality of life buzzkill and I appreciate us being on a path to a fix!

Sorry I didn’t look at this sooner! Somehow this never made it to the top of my inbox.

So here’s what’s going on:

  1. Magnifier enables UIA
  2. ScreenInfoUiaProviderBase::GetSelection() is called
    • This is called frequently to get the cursor position.
  3. UiaTextRangeBase::GetBoundingRectangles() is called
    • This is called frequently to figure out where the cursor is on the screen and move magnifier’s view appropriately.
  4. Viewport::CompareInBounds(<cursorPosition>, <topOfViewport>) is called and crashes because <cursorPosition> is out of bounds from the buffer size (as mentioned above).

I’m hesitant to clamp the coordinate because I feel like the coordinate is wrong in the first place. Why is the cursor position {120,8} when the buffer is 120 cells wide? The cursor should be going from {0,9} to {119,8} when it wraps.

@miniksa @lhecker Any idea why the cursor’s position would be off the right boundary? I imagine we’re using the OutputCellIterator (or one of the iterators we have) to wrap the cursor properly, so that’s the part that’s confusing to me.

@carlos-zamora I’m deferring this one to you. Seems like we could easily just add a check to see if startAnchor.x() >= bufferSize.RightExclusive(), and clamp the coordinate in that case. But maybe Viewport::IsInBounds(..., allowEndExclusive=true) needs to be more forgiving for this scenario? IDK.

It should definitely get a test though, and you’re the UIA test man for sure.

For what it’s worth anyone trying to use nodejs / npm on Windows is going to get bitten REALLY hard by this bug. It makes installing packages almost impossible.

Triaging this into v2 since we have a line of code identified. Thanks!