[Product-Conhost] Console crashes when resizing #10463

Closed
opened 2026-01-31 02:22:13 +00:00 by claunia · 5 comments
Owner

Originally created by @magiblot on GitHub (Sep 2, 2020).

Environment

Windows build number: 10.0.19041.450
Windows Terminal version (if applicable): N/A

Steps to reproduce

This can be reproduced easily when using any of the sample applications from the port of Turbo Vision I maintain at https://github.com/magiblot/tvision (precompiled binaries available).

I enabled the 'Wrap text output on resize' option in the 'Layout' tab of Properties:

imatge

From the Console API perspective, with this option enabled, I can enlarge the console buffer size, but not shrink it: the window size (srWindow) is shrinked instead (actually: the buffer can be shrinked horizontally, but not vertically). Since I want the application to fit perfectly in the console window so that no scrollbars are visible, I readjust the buffer size every time I get a WINDOW_BUFFER_SIZE_EVENT event:

55535422aa/source/linux/win32con.cpp (L86)

void Win32ConsoleStrategy::reloadScreenBufferInfo()
{
    // Set the buffer size to the viewport size so that the scrollbars
    // do not become visible after resizing.
    GetConsoleScreenBufferInfo(consoleHandle[cnOutput], &sbInfo);
    sbInfo.dwSize.X = sbInfo.srWindow.Right - sbInfo.srWindow.Left + 1;
    sbInfo.dwSize.Y = sbInfo.srWindow.Bottom - sbInfo.srWindow.Top + 1;
    // Note that this also causes the console to crash often while resizing,
    // hence the console recovery feature.
    SetConsoleScreenBufferSize(consoleHandle[cnOutput], sbInfo.dwSize);
}

Expected behavior

The console window size should match the buffer size after resizing (given the API calls exposed above).

Actual behavior

Windows Console Turbo Vision

The console crashes and GetNumberOfConsoleInputEvents fails with ERROR_PIPE_NOT_CONNECTED. When I detect this situation, I call FreeConsole() and spawn a new console with AllocConsole(). This is the reason why new consoles keep popping up in the GIF.

Here is the crash event:

XML View
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
 <System>
  <Provider Name="Application Error" /> 
  <EventID Qualifiers="0">1000</EventID> 
  <Version>0</Version> 
  <Level>2</Level> 
  <Task>100</Task> 
  <Opcode>0</Opcode> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2020-09-02T15:15:23.3664258Z" /> 
  <EventRecordID>4505</EventRecordID> 
  <Correlation /> 
  <Execution ProcessID="0" ThreadID="0" /> 
  <Channel>Application</Channel> 
  <Computer>DESKTOP-CDENBB3</Computer> 
  <Security /> 
 </System>
 <EventData>
  <Data>conhost.exe</Data> 
  <Data>10.0.19041.153</Data> 
  <Data>947f4411</Data> 
  <Data>ucrtbase.dll</Data> 
  <Data>10.0.19041.423</Data> 
  <Data>ccf6a09c</Data> 
  <Data>c0000409</Data> 
  <Data>000000000007284e</Data> 
  <Data>14d0</Data> 
  <Data>01d6813bd9f9715d</Data> 
  <Data>C:\WINDOWS\system32\conhost.exe</Data> 
  <Data>C:\WINDOWS\System32\ucrtbase.dll</Data> 
  <Data>102ea365-6f89-4c02-8d7d-7b29f3f774db</Data> 
  <Data /> 
  <Data /> 
 </EventData>
</Event>

Also in binary format:
error.evtx.zip

Originally created by @magiblot on GitHub (Sep 2, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.19041.450 Windows Terminal version (if applicable): N/A ``` # Steps to reproduce This can be reproduced easily when using any of the sample applications from the port of Turbo Vision I maintain at https://github.com/magiblot/tvision ([precompiled binaries](https://github.com/magiblot/tvision/releases/tag/r586) available). I enabled the 'Wrap text output on resize' option in the 'Layout' tab of Properties: ![imatge](https://user-images.githubusercontent.com/20713561/92008311-4c7ddf80-ed47-11ea-9643-acdd0a8819c3.png) From the Console API perspective, with this option enabled, I can enlarge the console buffer size, but not shrink it: the window size ([`srWindow`](https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str)) is shrinked instead (actually: the buffer can be shrinked horizontally, but not vertically). Since I want the application to fit perfectly in the console window so that no scrollbars are visible, I readjust the buffer size every time I get a `WINDOW_BUFFER_SIZE_EVENT` event: https://github.com/magiblot/tvision/blob/55535422aa7c44437ee9845e7238649b1d6b94ed/source/linux/win32con.cpp#L86 ```c++ void Win32ConsoleStrategy::reloadScreenBufferInfo() { // Set the buffer size to the viewport size so that the scrollbars // do not become visible after resizing. GetConsoleScreenBufferInfo(consoleHandle[cnOutput], &sbInfo); sbInfo.dwSize.X = sbInfo.srWindow.Right - sbInfo.srWindow.Left + 1; sbInfo.dwSize.Y = sbInfo.srWindow.Bottom - sbInfo.srWindow.Top + 1; // Note that this also causes the console to crash often while resizing, // hence the console recovery feature. SetConsoleScreenBufferSize(consoleHandle[cnOutput], sbInfo.dwSize); } ``` # Expected behavior The console window size should match the buffer size after resizing (given the API calls exposed above). # Actual behavior ![Windows Console Turbo Vision](https://user-images.githubusercontent.com/20713561/92006888-91087b80-ed45-11ea-854a-a31bd4d08726.gif) The console crashes and `GetNumberOfConsoleInputEvents` fails with `ERROR_PIPE_NOT_CONNECTED`. When I detect this situation, I call `FreeConsole()` and spawn a new console with `AllocConsole()`. This is the reason why new consoles keep popping up in the GIF. Here is the crash event: <details> <summary>XML View</summary> ```xml <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application Error" /> <EventID Qualifiers="0">1000</EventID> <Version>0</Version> <Level>2</Level> <Task>100</Task> <Opcode>0</Opcode> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2020-09-02T15:15:23.3664258Z" /> <EventRecordID>4505</EventRecordID> <Correlation /> <Execution ProcessID="0" ThreadID="0" /> <Channel>Application</Channel> <Computer>DESKTOP-CDENBB3</Computer> <Security /> </System> <EventData> <Data>conhost.exe</Data> <Data>10.0.19041.153</Data> <Data>947f4411</Data> <Data>ucrtbase.dll</Data> <Data>10.0.19041.423</Data> <Data>ccf6a09c</Data> <Data>c0000409</Data> <Data>000000000007284e</Data> <Data>14d0</Data> <Data>01d6813bd9f9715d</Data> <Data>C:\WINDOWS\system32\conhost.exe</Data> <Data>C:\WINDOWS\System32\ucrtbase.dll</Data> <Data>102ea365-6f89-4c02-8d7d-7b29f3f774db</Data> <Data /> <Data /> </EventData> </Event> ``` </details> Also in binary format: [error.evtx.zip](https://github.com/microsoft/terminal/files/5163645/error.evtx.zip)
claunia added the Resolution-Duplicate label 2026-01-31 02:22:13 +00:00
Author
Owner

@j4james commented on GitHub (Sep 2, 2020):

This might be related to issue #1976.

@j4james commented on GitHub (Sep 2, 2020): This might be related to issue #1976.
Author
Owner

@magiblot commented on GitHub (Sep 3, 2020):

Yes, you are right. The issue can be worked around by setting the cursor position to (0, 0) before resizing the buffer. It still crashes if the console is resized to the minimum allowed, but that is less likely to happen.

@magiblot commented on GitHub (Sep 3, 2020): Yes, you are right. The issue can be worked around by setting the cursor position to (0, 0) before resizing the buffer. It still crashes if the console is resized to the minimum allowed, but that is less likely to happen.
Author
Owner

@magiblot commented on GitHub (Sep 3, 2020):

Feel free to mark as duplicate.

@magiblot commented on GitHub (Sep 3, 2020): Feel free to mark as duplicate.
Author
Owner

@DHowett commented on GitHub (Sep 4, 2020):

Thanks for following up, and thanks @j4james for finding the duplicate.

/dup #1976.

@DHowett commented on GitHub (Sep 4, 2020): Thanks for following up, and thanks @j4james for finding the duplicate. /dup #1976.
Author
Owner

@ghost commented on GitHub (Sep 4, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Sep 4, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10463