terminal: Crash when attempting to compare selection endpoints with UIA

Environment

Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd] 21H1 (19603.1000)
Windows Terminal version (if applicable): inbox console

Any other software? NVDA 2020.2

Steps to reproduce

  1. Start the latest NVDA alpha snapshot.
  2. In NVDA advanced settings, enable “use UI Automation to access the Windows Console when available”.
  3. Open cmd.
  4. Ssh to an Ubuntu 18.04 system.
  5. Run 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:

ERROR - eventHandler.executeEvent (04:42:19.980) - MainThread (21752):
error executing event: caret on <NVDAObjects.Dynamic_WinConsoleUIAEditableTextWithAutoSelectDetectionUIA object at 0x070733B0> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 155, in executeEvent
  File "eventHandler.pyc", line 92, in __init__
  File "eventHandler.pyc", line 100, in next
  File "NVDAObjects\behaviors.pyc", line 191, in event_caret
  File "editableText.pyc", line 333, in detectPossibleSelectionChange
  File "editableText.pyc", line 340, in _updateSelectionAnchor
  File "NVDAObjects\UIA\__init__.pyc", line 776, in compareEndPoints
  File "comtypesMonkeyPatches.pyc", line 26, in __call__
_ctypes.COMError: (-2147418113, 'Catastrophic failure', (None, None, None, 0, None))

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)!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

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.

(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 ☺️ )