Skip to content

Windows Curses Display Infinite Loop

Host environment

  • Operating system: Windows 10 22H2
  • OS/kernel version: 19045.5608
  • Architecture: x86-64
  • QEMU flavor: qemu-system-x86_64
  • QEMU version: QEMU emulator version 9.2.91 (v10.0.0-rc1-12076-g50ecdaef16)
  • QEMU command line:
    ./qemu-system-x86_64 -display curses

Emulated/Virtualized environment

  • Operating system: N/A
  • OS/kernel version: N/A
  • Architecture: x86-64

Description of problem

The out-of-the-box qemu-system-x86_64 -display curses on Windows loops forever while displaying "VGA Blank Mode" instead of booting like qemu-system-x86_64 does.

This is caused by an infinite loop in the below simplified code in curses_refresh in ui/curses.c:

    int chr;
    // ...trimmed
    while (1) {
        /* while there are any pending key strokes to process */
        chr = console_getch(&maybe_keycode);

        if (chr == -1) 
            break;
    // ...trimmed
    }

console_getch has return type wint_t. However, on Windows, wint_t is unsigned short. Therefore when console_getch returns -1, the -1 value of unsigned short will be silently converted into the int value 65535. This causes 65535 == -1 to always be false, and the loop will never break. I can send a patch to qemu-devel which retypes chr to wint_t and replaces occurences of -1 with WEOF (an alias for (wint_t) -1).

Steps to reproduce

  1. Install qemu-w64-setup-20250326.exe Windows qemu from https://qemu.weilnetz.de/w64/2025/
  2. Run ./qemu-system-x86_64 -display curses
  3. "VGA Blank Mode" will appear on the screen forever

Additional information

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information