ConHost crash when calling GetConsoleMode after enabling ANSI Alternate Screen #473

Closed
opened 2026-01-30 21:53:11 +00:00 by claunia · 3 comments
Owner

Originally created by @LPGhatguy on GitHub (Dec 6, 2018).

Microsoft Windows [Version 10.0.17134.407]

Steps:

The crash is not 100%, but pretty close.

I'm working on a terminal abstraction library in Rust. I turn on ANSI terminal emulation when available, and provide a method to enable 'raw' mode (toggling ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT) as well as a method to switch to the ANSI alternate screen (printing ESC [ ? 1 0 4 9 h)

If I switch to the alternate screen and then enable raw mode, ConHost crashes and closes the terminal window:

Faulting application name: conhost.exe, version: 10.0.17134.1, time stamp: 0xda078a31
Faulting module name: ntdll.dll, version: 10.0.17134.376, time stamp: 0x60d78cf9
Exception code: 0xc0000374
Fault offset: 0x00000000000f4d7b
Faulting process id: 0x22fc
Faulting application start time: 0x01d48da85558ec22
Faulting application path: C:\WINDOWS\system32\conhost.exe
Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
Report Id: f3a823ce-1add-4e97-8cc8-4cc6d116d2b5
Faulting package full name: 
Faulting package-relative application ID: 

If I do these operations in the reverse order, everything is fine. After adding additional instrumentation to try to track winapi calls, it looks like the attached sample dies trying to call GetConsoleMode.

Originally created by @LPGhatguy on GitHub (Dec 6, 2018). ``` Microsoft Windows [Version 10.0.17134.407] ``` Steps: * Open a new command prompt * Run the sample, written in Rust: https://github.com/LPGhatguy/conhost-crash-repro The crash is not 100%, but pretty close. I'm working on a terminal abstraction library in Rust. I turn on ANSI terminal emulation when available, and provide a method to enable 'raw' mode (toggling `ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT`) as well as a method to switch to the ANSI alternate screen (printing `ESC [ ? 1 0 4 9 h`) If I switch to the alternate screen and then enable raw mode, ConHost crashes and closes the terminal window: ``` Faulting application name: conhost.exe, version: 10.0.17134.1, time stamp: 0xda078a31 Faulting module name: ntdll.dll, version: 10.0.17134.376, time stamp: 0x60d78cf9 Exception code: 0xc0000374 Fault offset: 0x00000000000f4d7b Faulting process id: 0x22fc Faulting application start time: 0x01d48da85558ec22 Faulting application path: C:\WINDOWS\system32\conhost.exe Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll Report Id: f3a823ce-1add-4e97-8cc8-4cc6d116d2b5 Faulting package full name: Faulting package-relative application ID: ``` If I do these operations in the reverse order, everything is fine. After adding additional instrumentation to try to track winapi calls, it looks like the attached sample dies trying to call `GetConsoleMode`.
claunia added the Resolution-Duplicate label 2026-01-30 21:53:11 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Dec 6, 2018):

I'm 99% sure this is #162, fixed in the October Update

@zadjii-msft commented on GitHub (Dec 6, 2018): I'm 99% sure this is #162, fixed in the October Update
Author
Owner

@LPGhatguy commented on GitHub (Dec 6, 2018):

Cool, I'll try this again when my system gets 1809.

@LPGhatguy commented on GitHub (Dec 6, 2018): Cool, I'll try this again when my system gets 1809.
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 8, 2019):

I'll close this since we think it's a duplicate. If it continues to reproduce after you get 1809, please feel free to reopen it. Thanks!

@DHowett-MSFT commented on GitHub (Jan 8, 2019): I'll close this since we think it's a duplicate. If it continues to reproduce after you get 1809, please feel free to reopen it. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#473