Vb: conhost still crashes (disappears?) on resize in the alt buffer #6060

Open
opened 2026-01-31 00:28:49 +00:00 by claunia · 0 comments
Owner

Originally created by @joaobzrr on GitHub (Jan 21, 2020).

Windows build number: 19013.1102

Steps to reproduce

  • Disable "Wrap text output on resize" console option.
  • Compile the code below and run Visual Studio with the executable.
#include <windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    HANDLE con_out = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
    if (con_out != INVALID_HANDLE_VALUE)
    {
        DWORD con_out_mode;
        GetConsoleMode(con_out, &con_out_mode);
        con_out_mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
        SetConsoleMode(con_out, con_out_mode);

        printf("\x1b[?1049h");
        printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    }
}
  • Put a breakpoint at the first line of main() then start debugging or just hit F10 to have the debugger stop at the beginning. When you break, maximize the console window.
  • Step through until this line
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

is executed.

  • Restore the window to its previous size by clicking the restore button or double clicking the window title bar.

Expected behavior

The console window should remain visible.

Actual behavior

The program appears to crash, but it's actually still running. The console window disappears but the process is still visible in the task manager. You can't kill the process unless you close Visual Studio.

Originally created by @joaobzrr on GitHub (Jan 21, 2020). ``` Windows build number: 19013.1102 ``` # Steps to reproduce - Disable "Wrap text output on resize" console option. - Compile the code below and run Visual Studio with the executable. ```cpp #include <windows.h> #include <stdio.h> int main(int argc, char **argv) { HANDLE con_out = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); if (con_out != INVALID_HANDLE_VALUE) { DWORD con_out_mode; GetConsoleMode(con_out, &con_out_mode); con_out_mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; SetConsoleMode(con_out, con_out_mode); printf("\x1b[?1049h"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); } } ``` - Put a breakpoint at the first line of main() then start debugging or just hit F10 to have the debugger stop at the beginning. When you break, maximize the console window. - Step through until this line ```cpp printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); ``` is executed. - Restore the window to its previous size by clicking the restore button or double clicking the window title bar. # Expected behavior The console window should remain visible. # Actual behavior The program appears to crash, but it's actually still running. The console window disappears but the process is still visible in the task manager. You can't kill the process unless you close Visual Studio.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6060