Skip to content

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

@AntonLapounov

Description

@AntonLapounov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions