Skip to content
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

Could not attach console (windows error 6) when running cmd.exe #9867

Closed
XLTechie opened this issue Jul 3, 2019 · 7 comments · Fixed by #10964
Closed

Could not attach console (windows error 6) when running cmd.exe #9867

XLTechie opened this issue Jul 3, 2019 · 7 comments · Fixed by #10964
Milestone

Comments

@XLTechie
Copy link
Collaborator

XLTechie commented Jul 3, 2019

Note: the below only occurs if the advanced "Use
UI Automation to access the windows console when available" option is turned off. In
other words: the current default condition.

Steps to reproduce:

Run a recent NVDA alpha or beta.
Perform Windows+r, "cmd", enter.

Actual behavior:

A windows error sound occurs on launch.

The console appears to act normally after that, although when doing a "cls" NVDA is silent (does not read the prompt), until enter is pressed a second time, though this may be unrelated and happens in older versions.

Various warnings, and a "could not attach console: windows error (6, 'the handle is invalid')" are logged.

Expected behavior:

No windows error sound, no logged warnings or errors.

System configuration

NVDA installed/portable/running from source:

Installed

NVDA version:

beta-17929

Windows version:

Windows 10 Home 1903, 64 bit

Name and version of other software in use when reproducing the issue:

Windows command shell (cmd.exe)

Other information about your system:

AMD

Other questions

Does the issue still occur after restarting your PC?

Yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

A few recent betas have done this.
Edit: also occurs on an installed version of alpha-17928,9dfbd2ee (7/3/2019).
Doesn't happen with 2019.1.1, although the (likely unrelated) cls problem does.

nvda-cmd-errors.txt

@XLTechie
Copy link
Collaborator Author

XLTechie commented Jul 3, 2019

CC @codeofdusk

@Adriani90
Copy link
Collaborator

Adriani90 commented Jul 3, 2019

@XLTechie could you test please with last alpha_ I cannot reproduce this issue in NVDA alpha-17901,ac6ea147.

@Brian1Gaff
Copy link

Brian1Gaff commented Jul 4, 2019 via email

@XLTechie
Copy link
Collaborator Author

XLTechie commented Jul 4, 2019

@Adriani90 the alpha you tested with is not the most recent alpha. It is from July 1, which is older than the beta I was testing with.
But you are correct that it doesn't occur in that alpha.
However, it does occur in the most recent alpha: alpha-17928,9dfbd2ee (July 3rd).

@lukaszgo1
Copy link
Contributor

I cannot reproduce it on my main machine running Windows 7 nor on my vm running Windows 10 1809. I can however reproduce it on Windows 10 1903 though it isn't happening all the time. I've tried tracking it down to a specific build of Alpha without much luck - the Alpha 17901,ac6ea147 mentioned by @Adriani90 also exhibits this issue occasionally. Logging this specific exception at a higher log level and therefore avoiding error sound is covered by #7250 and the error sound isn't present in a release version.

@AAClause
Copy link
Contributor

I confirm the issue with the current alpha version (alpha-18450,8c27752f), many recent alpha and versions mentioned by @XLTechie. With fresh portable versions and installed versions (with add-ons disabled). Running on Windows 10Ver1903.

When Windows Console support is set to UIA, the bug doesn't seem to occur. But unfortunately I prefer legacy mode for now (because many other odd behaviors).

However the bug doesn't happen systematically.

When this happens, I also have the following error is raised in the log and I'm unable to navigate in the Terminal content:

DEBUGWARNING - winConsoleHandler.connectConsole (09:31:49.453):
Could not attach console: OSError(9, The handle is invalid, None, 6)
ERROR - NVDAObjects.behaviors.LiveText._monitor (09:31:49.471):
Error getting initial lines
Traceback (most recent call last):
  File "NVDAObjects\behaviors.pyc", line 271, in _monitor
  File "NVDAObjects\window\winConsole.pyc", line 62, in _getTextLines
  File "winConsoleHandler.pyc", line 127, in getConsoleVisibleLines
  File "wincon.pyc", line 77, in GetConsoleScreenBufferInfo
OSError: [WinError 6] The handle is invalid

@lukaszgo1
Copy link
Contributor

cc @codeofdusk again. Also @Andre9642 if you are experiencing problems with new UIA support for consoles could you open a bug report about them? UIA would be the default for 2019.3, and it is important to make it as good as possible before the release.

seanbudd pushed a commit that referenced this issue Jun 21, 2022
…(Windows 11 Sun Valley 2) (#10964)

Supersedes #9771 and #10716. Closes #1682. Closes #8653. Closes #9867. Closes #11172. Closes #11554.

Summary of the issue:

Microsoft has significantly improved performance and reliability of UIA console:
* microsoft/terminal#4018 is an almost complete rewrite of the UIA code which makes the console's UIA implementation more closely align with the API specification.
* microsoft/terminal#10886, microsoft/terminal#10925, and microsoft/terminal#11253 form a robust testing methodology for the UIA implementation, including bug fixes in response to newly added tests based on Word's UIA implementation.
* microsoft/terminal#11122 removes the thousands of empty lines at the end of the console buffer, significantly improving performance and stability. Since all console text ranges are now within the text buffer's bounds, it is no longer possible for console to crash due to the manipulation by UIA clients of an out-of-bounds text range.
* Countless other accessibility-related PRs too numerous to list here.

We should enable UIA support on new Windows Console builds by default for performance improvement and controllable password suppression.

Description of how this pull request fixes the issue:

This PR:
* Exposes all three options for the UIA console feature flag in the UI (replaces the UIA check box with a combo box).
* Adds a runtime check to test if `apiLevel >= FORMATTED`, and use UIA in this case when the user preference is auto. This is the case on Windows 11 Sun Valley 2 (SV2) available now in beta and set for release in the second half of 2022.
@nvaccessAuto nvaccessAuto modified the milestone: 2022.3 Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants