Skip to content

Fix A11y EndExclusive Error for Move & Expand - #7677

Merged
5 commits merged into
masterfrom
dev/cazamor/a11y/end-exclusive-out-of-bounds
Sep 23, 2020
Merged

5 commits merged into
masterfrom
dev/cazamor/a11y/end-exclusive-out-of-bounds

Conversation

@carlos-zamora

@carlos-zamora Carlos Zamora (carlos-zamora) commented Sep 18, 2020 •

Copy link
Copy Markdown

EndExclusive represents the end of the buffer. This is designed to not
point to any data on the buffer. UiaTextRange would point to this
EndExclusive and then attempt to move based on it. However, since it
does not point to any data, it could experience undefined behavior or
(inevitably) crash from running out of bounds.

This PR specifically checks for expansion and movement at that point,
and prevents us from moving beyond it. There are plans in the future to
define the "end" as the last character in the buffer. Until then, this
solution will suffice and provide correct behavior that doesn't crash.

Validation Steps Performed

Performed the referenced bugs' repro steps and added test coverage.

Closes MSFT-20458595
Closes #7663
Closes #7664

@ghost ghost added Area-Accessibility Issues related to accessibility Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Conhost For issues in the Console codebase Severity-Crash Crashes are real bad news. labels Sep 18, 2020
@DHowett

Copy link
Copy Markdown
Member
  • did you figure out how we could end up with -1​​​​​​​ in a uia endpoint?
  • it looks like this stops all movement at the end-degenerate. what about moving backwards?

@DHowett

Copy link
Copy Markdown
Member

Build veyr mad

Comment thread src/buffer/out/textBuffer.cpp Resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Sep 18, 2020
@codeofdusk

Copy link
Copy Markdown
Contributor

CC Simon Jaeger (@Simon818)


// tests for second line of text
{ { 0, 1 }, {{ 0, 1 }, { 0, 1 }} },
{ { 0, 1 }, {{ 0, 1 }, { 5, 0 }} },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which of the code changes made this change. Is this good and righteous? It seems like it is because a11y defines the word to be the word + all the spaces after it, so you're inside the spaces at 0,1... so the word starts at 5,0... but why was this broken before?

@carlos-zamora Carlos Zamora (carlos-zamora) Sep 21, 2020 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was a mistake on my part back when I wrote these tests. You're right to be concerned but here's my reasoning on why this is the right fix:

You have the following text:

word other
  more   words

You're current position is where the X is (0,1):

word other
X more   words

When we get the previous word, we're supposed to wrap around to encompass "other". Before, on accident, we would hit the left boundary and not wrap. So we would actually return the whitespace on the second line between the left boundary and "more".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did this test not fail then? o_O

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test didn't fail because I wrote it incorrectly. It used to expect the whitespace. It should have expected the word on the previous line.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't figure out how to permalink code, but you want to look at textbuffer.cpp line 1000

if (target.X == GetSize().Left())

We were treating "Left" as "Origin" and refusing to expand left.

Comment thread src/buffer/out/textBuffer.cpp Resolved
@carlos-zamora Carlos Zamora (carlos-zamora) added the AutoMerge Marked for automatic merge by the bot when requirements are met label Sep 23, 2020
@ghost

Copy link
Copy Markdown

Hello Carlos Zamora (@carlos-zamora)!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
ghost merged commit 40893b2 into master Sep 23, 2020
@ghost
ghost deleted the dev/cazamor/a11y/end-exclusive-out-of-bounds branch September 23, 2020 20:06
@codeofdusk

Copy link
Copy Markdown
Contributor

Yeah. Gonna resolve this comment.

Carlos Zamora (@carlos-zamora) presumably in a follow-up PR?

@carlos-zamora

Copy link
Copy Markdown
Author

Yeah. Gonna resolve this comment.

Carlos Zamora (@carlos-zamora) presumably in a follow-up PR?

Just a thought to play around with. This could be a part of #6453, since we'll hit that case often then.

@DHowett

Copy link
Copy Markdown
Member

This fix was just released as part of Windows in Insider Build 20236!

Dustin L. Howett (DHowett) pushed a commit that referenced this pull request Oct 19, 2020
`EndExclusive` represents the end of the buffer. This is designed to not
point to any data on the buffer. UiaTextRange would point to this
`EndExclusive` and then attempt to move based on it. However, since it
does not point to any data, it could experience undefined behavior or
(inevitably) crash from running out of bounds.

This PR specifically checks for expansion and movement at that point,
and prevents us from moving beyond it. There are plans in the future to
define the "end" as the last character in the buffer. Until then, this
solution will suffice and provide correct behavior that doesn't crash.

## Validation Steps Performed
Performed the referenced bugs' repro steps and added test coverage.

Closes MSFT-20458595
Closes #7663
Closes #7664

(cherry picked from commit 40893b2)
ghost pushed a commit that referenced this pull request Oct 27, 2020
In nvaccess/nvda#11428 (comment),
Andre9642 reported a Conhost crash when switching to/from the alt buffer
a few times with a Braille display connected. Upon further
investigation, @carlos-zamora and I discovered that the FailFast was in
`GetText`: more checks similar to #7677 were needed for this case.

Tested with NVDA using a [Focus](https://www.freedomscientific.com/products/blindness/focus40brailledisplay/) Braille display.

Improves nvaccess/nvda#11428
Dustin L. Howett (DHowett) pushed a commit that referenced this pull request Oct 28, 2020
In nvaccess/nvda#11428 (comment),
Andre9642 reported a Conhost crash when switching to/from the alt buffer
a few times with a Braille display connected. Upon further
investigation, @carlos-zamora and I discovered that the FailFast was in
`GetText`: more checks similar to #7677 were needed for this case.

Tested with NVDA using a [Focus](https://www.freedomscientific.com/products/blindness/focus40brailledisplay/) Braille display.

Improves nvaccess/nvda#11428

(cherry picked from commit 60437b8)
@ghost

Copy link
Copy Markdown

🎉Windows Terminal v1.4.3141.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost

Copy link
Copy Markdown

🎉Windows Terminal Preview v1.5.3142.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Accessibility Issues related to accessibility AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Conhost For issues in the Console codebase Severity-Crash Crashes are real bad news.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conhost crash (unknown cause) with UIA text range at {0, -1} conhost crash in narrator scan mode when jumping to heading 1

4 participants