Conhost crashes after SetConsoleScreenBufferSize call if wrapping on resize is enabled #12983

Open
opened 2026-01-31 03:30:39 +00:00 by claunia · 0 comments
Owner

Originally created by @AntonLapounov on GitHub (Mar 12, 2021).

Environment

Windows build number: 10.0.19042.867 (20H2)
conhost.exe version: 10.0.19041.746

Steps to reproduce

  • Start a Command Prompt.
  • Open the properties and make sure Wrap text output on resize is enabled.
  • Launch the program below.
#include <Windows.h>

int main()
{
    const int Width = 40, Height = 20;

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SMALL_RECT window = { 0, 0, Width - 1, Height - 1 };
    COORD size = { Width, Height };

    if (SetConsoleWindowInfo(hConsole, TRUE, &window))
    {
        // BUG: conhost.exe crashes after this call if "Wrap text output on resize" is enabled
        SetConsoleScreenBufferSize(hConsole, size);
    }
}

Expected behavior

No crash.

Actual behavior

Most of the time conhost.exe crashes with the following call stack:

KERNELBASE!RaiseException
ucrtbase!_CxxThrowException
conhost!wil::details::ThrowResultExceptionInternal
conhost!wil::ThrowResultException
conhost!wil::details::ReportFailure
conhost!wil::details::ReportFailure_Hr
conhost!wil::details::in1diag3::_Throw_Hr
conhost!wil::details::in1diag3::Throw_HrIf
conhost!TextBufferCellIterator::{ctor}
conhost!TextBuffer::GetCellDataAt
conhost!Microsoft::Console::Render::Renderer::_PaintBufferOutput
conhost!Microsoft::Console::Render::Renderer::_PaintFrameForEngine
conhost!Microsoft::Console::Render::Renderer::PaintFrame
conhost!Microsoft::Console::Render::RenderThread::_ThreadProc
KERNEL32!BaseThreadInitThunk
ntdll!RtlUserThreadStart

The same program works correctly on Windows 7, so this is a regression. I could not find any open issues that might be duplicates of this one. Cc @zadjii-msft @j4james.

Originally created by @AntonLapounov on GitHub (Mar 12, 2021). # Environment Windows build number: 10.0.19042.867 (20H2) conhost.exe version: 10.0.19041.746 # Steps to reproduce * Start a Command Prompt. * Open the properties and make sure _Wrap text output on resize_ is enabled. * Launch the program below. ```c #include <Windows.h> int main() { const int Width = 40, Height = 20; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); SMALL_RECT window = { 0, 0, Width - 1, Height - 1 }; COORD size = { Width, Height }; if (SetConsoleWindowInfo(hConsole, TRUE, &window)) { // BUG: conhost.exe crashes after this call if "Wrap text output on resize" is enabled SetConsoleScreenBufferSize(hConsole, size); } } ``` # Expected behavior No crash. # Actual behavior Most of the time conhost.exe crashes with the following call stack: ``` KERNELBASE!RaiseException ucrtbase!_CxxThrowException conhost!wil::details::ThrowResultExceptionInternal conhost!wil::ThrowResultException conhost!wil::details::ReportFailure conhost!wil::details::ReportFailure_Hr conhost!wil::details::in1diag3::_Throw_Hr conhost!wil::details::in1diag3::Throw_HrIf conhost!TextBufferCellIterator::{ctor} conhost!TextBuffer::GetCellDataAt conhost!Microsoft::Console::Render::Renderer::_PaintBufferOutput conhost!Microsoft::Console::Render::Renderer::_PaintFrameForEngine conhost!Microsoft::Console::Render::Renderer::PaintFrame conhost!Microsoft::Console::Render::RenderThread::_ThreadProc KERNEL32!BaseThreadInitThunk ntdll!RtlUserThreadStart ``` The same program works correctly on Windows 7, so this is a regression. I could not find any open issues that might be duplicates of this one. Cc @zadjii-msft @j4james.
claunia added the Resolution-Duplicate label 2026-01-31 03:30:39 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12983