Command prompt crashes when the window width is changed. #19134

Closed
opened 2026-01-31 06:34:44 +00:00 by claunia · 5 comments
Owner

Originally created by @tyan0 on GitHub (Dec 24, 2022).

Windows Terminal version

N/A [Is this the right place to report a bug of conventional command prompt (not in Windows Terminal, not legacy mode)?]

Windows build number

10.0.19045.2364

Other Software

OS: Windows 10 Professional (Japanese, 64bit)
The test case: The following code.

Steps to reproduce

  1. Compile the following test case.
#include <windows.h>
#include <stdio.h>

int main()
{
	DWORD mode;
	GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &mode);
	SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
	for (;;) {
		printf("\033[10;40H日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語");
	}
	return 0;
}
  1. Open command prompt window (cmd.exe).
  2. Execute the test case.
  3. Change the window width repeatedly.

Expected Behavior

Command prompt window stays opened, and window width is changed.

Actual Behavior

Command prompt window crashes. Even after window is closed, the test case is still running in background.

  • I confirmed this problem in Windows 10 2004, 21H2 and 22H2.
  • This does not seem to happen in Windows 11.
  • If the printed string is only ASCII chars (not multibyte), the problem does not occur.
Originally created by @tyan0 on GitHub (Dec 24, 2022). ### Windows Terminal version N/A [Is this the right place to report a bug of conventional command prompt (not in Windows Terminal, not legacy mode)?] ### Windows build number 10.0.19045.2364 ### Other Software OS: Windows 10 Professional (Japanese, 64bit) The test case: The following code. ### Steps to reproduce 1) Compile the following test case. ``` #include <windows.h> #include <stdio.h> int main() { DWORD mode; GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &mode); SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING); for (;;) { printf("\033[10;40H日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語日本語"); } return 0; } ``` 2) Open command prompt window (cmd.exe). 3) Execute the test case. 4) Change the window width repeatedly. ### Expected Behavior Command prompt window stays opened, and window width is changed. ### Actual Behavior Command prompt window crashes. Even after window is closed, the test case is still running in background. - I confirmed this problem in Windows 10 2004, 21H2 and 22H2. - This does not seem to happen in Windows 11. - If the printed string is only ASCII chars (not multibyte), the problem does not occur.
claunia added the Needs-TriageIssue-Bug labels 2026-01-31 06:34:45 +00:00
Author
Owner

@kumaran-id-git commented on GitHub (Dec 29, 2022):

@tyan0 Crash dmp or stack trace available for this issue ?

@kumaran-id-git commented on GitHub (Dec 29, 2022): @tyan0 Crash dmp or stack trace available for this issue ?
Author
Owner

@tyan0 commented on GitHub (Dec 29, 2022):

Thanks for the reply. I have attached the crash dump generated by ProcDump v11.0 and the stack trace created by GDB as well as event log. Are these that you requested?
conhost.exe_221229_224825.zip
conhost_bt.log
conhost_crash.zip

@tyan0 commented on GitHub (Dec 29, 2022): Thanks for the reply. I have attached the crash dump generated by ProcDump v11.0 and the stack trace created by GDB as well as event log. Are these that you requested? [conhost.exe_221229_224825.zip](https://github.com/microsoft/terminal/files/10319847/conhost.exe_221229_224825.zip) [conhost_bt.log](https://github.com/microsoft/terminal/files/10319875/conhost_bt.log) [conhost_crash.zip](https://github.com/microsoft/terminal/files/10319937/conhost_crash.zip)
Author
Owner

@tyan0 commented on GitHub (Dec 29, 2022):

Here is the call stack of the crash dump analyzed using Visual Studio 2022.

KERNELBASE.dll!RaiseFailFastException()
conhost.exe!wil::details::WilDynamicLoadRaiseFailFastException(struct _EXCEPTION_RECORD *,struct _CONTEXT *,unsigned long)
conhost.exe!wil::details::WilRaiseFailFastException(struct _EXCEPTION_RECORD *,struct _CONTEXT *,unsigned long)
conhost.exe!wil::details::WilFailFast(struct wil::FailureInfo const &)
conhost.exe!wil::details::ReportFailure()
conhost.exe!wil::details::ReportFailure_Hr(void *,unsigned int,char const *,char const *,char const *,void *,enum wil::FailureType,long)
conhost.exe!wil::details::in1diag3::_FailFast_Unexpected(void *,unsigned int,char const *)
conhost.exe!TextBuffer::_PrepareForDoubleByteSequence(class DbcsAttribute)
conhost.exe!TextBuffer::InsertCharacter(class std::basic_string_view<unsigned short,struct std::char_traits<unsigned short> >,class DbcsAttribute,class TextAttribute)
conhost.exe!SCREEN_INFORMATION::ResizeWithReflow(struct _COORD)
conhost.exe!SCREEN_INFORMATION::ResizeScreenBuffer(struct _COORD,bool)
conhost.exe!SCREEN_INFORMATION::_AdjustScreenBuffer(struct tagRECT const * const)
conhost.exe!SCREEN_INFORMATION::ProcessResizeWindow(struct tagRECT const * const,struct tagRECT const * const)
conhost.exe!Microsoft::Console::Interactivity::Win32::Window::_HandleWindowPosChanged()
conhost.exe!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc()
conhost.exe!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)
user32.dll!UserCallWinProcCheckWow()
user32.dll!DispatchClientMessage()
user32.dll!__fnINLPWINDOWPOS()
ntdll.dll!KiUserCallbackDispatcherContinue()
win32u.dll!NtUserMessageCall()
user32.dll!RealDefWindowProcWorker()
user32.dll!RealDefWindowProcW()
uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *)
uxtheme.dll!OnDwpSysCommand()
uxtheme.dll!_ThemeDefWindowProc()
uxtheme.dll!ThemeDefWindowProcW()
user32.dll!DefWindowProcW()
conhost.exe!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc()
conhost.exe!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)
user32.dll!UserCallWinProcCheckWow()
user32.dll!DispatchClientMessage()
user32.dll!__fnDWORD()
ntdll.dll!KiUserCallbackDispatcherContinue()
win32u.dll!NtUserMessageCall()
user32.dll!RealDefWindowProcWorker()
user32.dll!RealDefWindowProcW()
uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *)
uxtheme.dll!OnDwpNcLButtonDown()
uxtheme.dll!_ThemeDefWindowProc()
uxtheme.dll!ThemeDefWindowProcW()
user32.dll!DefWindowProcW()
conhost.exe!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc()
conhost.exe!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)
user32.dll!UserCallWinProcCheckWow()
user32.dll!DispatchMessageWorker()
conhost.exe!ConsoleInputThreadProcWin32()
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
@tyan0 commented on GitHub (Dec 29, 2022): Here is the call stack of the crash dump analyzed using Visual Studio 2022. ``` KERNELBASE.dll!RaiseFailFastException() conhost.exe!wil::details::WilDynamicLoadRaiseFailFastException(struct _EXCEPTION_RECORD *,struct _CONTEXT *,unsigned long) conhost.exe!wil::details::WilRaiseFailFastException(struct _EXCEPTION_RECORD *,struct _CONTEXT *,unsigned long) conhost.exe!wil::details::WilFailFast(struct wil::FailureInfo const &) conhost.exe!wil::details::ReportFailure() conhost.exe!wil::details::ReportFailure_Hr(void *,unsigned int,char const *,char const *,char const *,void *,enum wil::FailureType,long) conhost.exe!wil::details::in1diag3::_FailFast_Unexpected(void *,unsigned int,char const *) conhost.exe!TextBuffer::_PrepareForDoubleByteSequence(class DbcsAttribute) conhost.exe!TextBuffer::InsertCharacter(class std::basic_string_view<unsigned short,struct std::char_traits<unsigned short> >,class DbcsAttribute,class TextAttribute) conhost.exe!SCREEN_INFORMATION::ResizeWithReflow(struct _COORD) conhost.exe!SCREEN_INFORMATION::ResizeScreenBuffer(struct _COORD,bool) conhost.exe!SCREEN_INFORMATION::_AdjustScreenBuffer(struct tagRECT const * const) conhost.exe!SCREEN_INFORMATION::ProcessResizeWindow(struct tagRECT const * const,struct tagRECT const * const) conhost.exe!Microsoft::Console::Interactivity::Win32::Window::_HandleWindowPosChanged() conhost.exe!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc() conhost.exe!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64) user32.dll!UserCallWinProcCheckWow() user32.dll!DispatchClientMessage() user32.dll!__fnINLPWINDOWPOS() ntdll.dll!KiUserCallbackDispatcherContinue() win32u.dll!NtUserMessageCall() user32.dll!RealDefWindowProcWorker() user32.dll!RealDefWindowProcW() uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *) uxtheme.dll!OnDwpSysCommand() uxtheme.dll!_ThemeDefWindowProc() uxtheme.dll!ThemeDefWindowProcW() user32.dll!DefWindowProcW() conhost.exe!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc() conhost.exe!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64) user32.dll!UserCallWinProcCheckWow() user32.dll!DispatchClientMessage() user32.dll!__fnDWORD() ntdll.dll!KiUserCallbackDispatcherContinue() win32u.dll!NtUserMessageCall() user32.dll!RealDefWindowProcWorker() user32.dll!RealDefWindowProcW() uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *) uxtheme.dll!OnDwpNcLButtonDown() uxtheme.dll!_ThemeDefWindowProc() uxtheme.dll!ThemeDefWindowProcW() user32.dll!DefWindowProcW() conhost.exe!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc() conhost.exe!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc(struct HWND__ *,unsigned int,unsigned __int64,__int64) user32.dll!UserCallWinProcCheckWow() user32.dll!DispatchMessageWorker() conhost.exe!ConsoleInputThreadProcWin32() kernel32.dll!BaseThreadInitThunk() ntdll.dll!RtlUserThreadStart() ```
Author
Owner

@j4james commented on GitHub (Dec 29, 2022):

This looks to me like a duplicate of #4907, which was fixed in 8e7a866b06 (_PrepareForDoubleByteSequence doesn't have a FAIL_FAST check anymore). I'm not sure if there is somewhere showing which build of Windows the fix was released in, but it wouldn't surprise me if it was Windows 11 only, which would explain why you're not seeing the crash there.

@j4james commented on GitHub (Dec 29, 2022): This looks to me like a duplicate of #4907, which was fixed in 8e7a866b06733ec20703541ded383d55a8ab561b (`_PrepareForDoubleByteSequence` doesn't have a `FAIL_FAST` check anymore). I'm not sure if there is somewhere showing which build of Windows the fix was released in, but it wouldn't surprise me if it was Windows 11 only, which would explain why you're not seeing the crash there.
Author
Owner

@tyan0 commented on GitHub (Jan 2, 2023):

Thanks for having a look. It seems that this issue is as you mentioned. Hopefully this fix will be applied to Windows 10 as well.

@tyan0 commented on GitHub (Jan 2, 2023): Thanks for having a look. It seems that this issue is as you mentioned. Hopefully this fix will be applied to Windows 10 as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19134