Dragging conhost across a DPI boundary crashes it (Debug only 🤞) #5638

Closed
opened 2026-01-31 00:18:01 +00:00 by claunia · 0 comments
Owner

Originally created by @zadjii-msft on GitHub (Dec 18, 2019).

Problem is in our WM_GETDPISCALEDSIZE handler:

    case WM_GETDPISCALEDSIZE:
    {
        // This message will send us the DPI we're about to be changed to.
        // Our goal is to use it to try to figure out the Window Rect that we'll need at that DPI to maintain
        // the same client rendering that we have now.

        // First retrieve the new DPI and the current DPI.
        DWORD const dpiProposed = (WORD)wParam;
        DWORD const dpiCurrent = g.dpi;

        // Now we need to get what the font size *would be* if we had this new DPI. We need to ask the renderer about that.
        const FontInfo& fiCurrent = ScreenInfo.GetCurrentFont();
        FontInfoDesired fiDesired(fiCurrent);
        FontInfo fiProposed(nullptr, 0, 0, { 0, 0 }, 0);
        ...

the line:

FontInfo fiProposed(nullptr, 0, 0, { 0, 0 }, 0);

crashes, because we're trying to make a string_view from a nullptr? The top of the stack is:

0:002> k
 # Child-SP          RetAddr           Call Site
00 00000032`ea2fd3c0 00007ff6`8c9f9647 OpenConsole!std::_WChar_traits<wchar_t>::length+0x4d 
01 00000032`ea2fd400 00007ff6`8c9fa396 OpenConsole!std::basic_string_view<wchar_t,std::char_traits<wchar_t> >::basic_string_view<wchar_t,std::char_traits<wchar_t> >+0x47 
02 00000032`ea2fd430 00007ff6`8c9f9d4b OpenConsole!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc+0x616 
03 00000032`ea2fdcb0 00007ffd`5e57e108 OpenConsole!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc+0xab  
...

I don't know when this regressed quite yet. Unsure if it repros in Release builds, or what. Doesn't repro in the 191206 VB_RELEASE build, nor the 191212 RS_ONECORE_DEP build. Maybe this is Debug only.

Originally created by @zadjii-msft on GitHub (Dec 18, 2019). Problem is in our `WM_GETDPISCALEDSIZE` handler: ```c++ case WM_GETDPISCALEDSIZE: { // This message will send us the DPI we're about to be changed to. // Our goal is to use it to try to figure out the Window Rect that we'll need at that DPI to maintain // the same client rendering that we have now. // First retrieve the new DPI and the current DPI. DWORD const dpiProposed = (WORD)wParam; DWORD const dpiCurrent = g.dpi; // Now we need to get what the font size *would be* if we had this new DPI. We need to ask the renderer about that. const FontInfo& fiCurrent = ScreenInfo.GetCurrentFont(); FontInfoDesired fiDesired(fiCurrent); FontInfo fiProposed(nullptr, 0, 0, { 0, 0 }, 0); ... ``` the line: ```c++ FontInfo fiProposed(nullptr, 0, 0, { 0, 0 }, 0); ``` crashes, because we're trying to make a string_view from a nullptr? The top of the stack is: ``` 0:002> k # Child-SP RetAddr Call Site 00 00000032`ea2fd3c0 00007ff6`8c9f9647 OpenConsole!std::_WChar_traits<wchar_t>::length+0x4d 01 00000032`ea2fd400 00007ff6`8c9fa396 OpenConsole!std::basic_string_view<wchar_t,std::char_traits<wchar_t> >::basic_string_view<wchar_t,std::char_traits<wchar_t> >+0x47 02 00000032`ea2fd430 00007ff6`8c9f9d4b OpenConsole!Microsoft::Console::Interactivity::Win32::Window::ConsoleWindowProc+0x616 03 00000032`ea2fdcb0 00007ffd`5e57e108 OpenConsole!Microsoft::Console::Interactivity::Win32::Window::s_ConsoleWindowProc+0xab ... ``` I don't know when this regressed quite yet. Unsure if it repros in Release builds, or what. Doesn't repro in the 191206 VB_RELEASE build, nor the 191212 RS_ONECORE_DEP build. Maybe this is Debug only.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5638