-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when attempting to compare selection endpoints with UIA #5309
Comments
For whatever it's worth, this doesn't crash Windows Terminal. |
(tentatively throwing this in the 21H1 milestone, but that's totally arbitrary. I figured this is a conhost bug, not a Terminal bug, so that's where it belongs. The team can overrule me |
Thanks! Marking it triaged. @carlos-zamora ACK if you've seen it. |
Yep! I was taking a look at it a bit today. This one is kind of surprising. |
Running |
Took a closer look at this today. It looks like the root cause is that when we switch over to the alt buffer, we are now in a state where the buffer size may have changed. So when you compare a @DHowett-MSFT suggested that we track which buffer the We could probably return a relevant |
What do you mean by the alt buffer? If the console is switching buffers, this also might explain some issues I've been seeing with |
To ask more succinctly: how do we respond to say "this comparison is simply invalid. it takes place in two different coordinate systems."? The alt buffer is a different "screen mode" for terminal applications. It hides whatever was on the screen prior and lets the application have its own sandbox. Once the application is done, it will turn off the alt buffer, permanently destroying its contents. |
Cc @michaelDCurran. |
Also cc @LeonarddeR (author of nvaccess/nvda#9660). Could you please provide advice here? |
Sorry, I'm not familiar enough with UIA to answer. Generally, applications I've seen don't have text ranges that behave like this (i.e. two text ranges from the same text where comparison is incompatible). A crash is definitely not the right thing to do though! |
For whatever it's worth, it does seem that, when I open a word document, get the text range for the document, open a second document, get that text range, and compare endpoints of the two ranges (from separate documents) it returns >>> ti=nav.makeTextInfo("all") # First document
>>> ti2=nav.makeTextInfo("all") # Second document
>>> ti.compareEndPoints(ti2,"endToStart")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "NVDAObjects\UIA\__init__.pyc", line 776, in compareEndPoints
File "comtypesMonkeyPatches.pyc", line 26, in __call__
_ctypes.COMError: (-2146233079, None, (None, None, None, 0, None)) |
Interesting. If that won’t throw off the works, that might be good for us. Ideally, in the long term, we would have different UIA parent objects for the different text buffers. |
## Summary of the Pull Request This is a quick-and-easy solution to #5309. If the ITextRangeProvider API allows us to take in two UiaTextRanges, we need to verify that they are both valid. With this PR, we make sure they both fit in the current TextBuffer. If not, we return `E_FAIL`. Though this doesn't prove that both UiaTextRanges are from the same TextBuffer, at the very least we don't crash and in cases where we can't make a valid comparison, we return an HRESULT failure. ## References #5406 - This should be the proper solution to this problem. Each UiaTextRange needs to be aware of which TextBuffer it came from. ## PR Checklist * [X] Closes #5309 ## Validation Steps Performed 1. generate enough output to cause the terminal to scroll 2. execute `nano` to make us go into the alternate buffer This previously crashed, now NVDA seems to detect that there was an error and keeps moving along.
🎉This issue was addressed in #5399, which has now been successfully released as Handy links: |
Environment
Steps to reproduce
sudo do-release-upgrade -d
.Expected behavior
NVDA reads the output, and the console remains functional.
Actual behavior
Windows Console crashes, and the following is written to the NVDA log:
Context
NVDA uses cursor changed events to detect and report selection changes to the user. It receives a cursor change event and compares the previous and current selection endpoints, which causes console to crash in this case. Is there anything I can do to help trace this on the console side?
Please push the fix for this issue to 21H1 as we'd really like to use UIA in console (especially after the excellent work in #4018 and #4495)!
The text was updated successfully, but these errors were encountered: