[Lldb-commits] [lldb] [lldb][windows] prevent IOHandlerProcessSTDIOWindows from consuming non text inputs (PR #175812)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 19 06:12:32 PST 2026


================
@@ -993,6 +996,20 @@ class IOHandlerProcessSTDIOWindows : public IOHandler {
       case WAIT_FAILED:
         goto exit_loop;
       case WAIT_OBJECT_0: {
+        if (isConsole) {
+          INPUT_RECORD inputRecord;
+          DWORD numRead = 0;
+          if (!PeekConsoleInput(hStdin, &inputRecord, 1, &numRead) ||
+              numRead == 0)
+            goto exit_loop;
+          // We only care about text input. Ignore all non text input events and
+          // let other IOHandlers handle them.
+          if (inputRecord.EventType != KEY_EVENT ||
+              !inputRecord.Event.KeyEvent.bKeyDown ||
+              inputRecord.Event.KeyEvent.uChar.AsciiChar == 0)
+            break;
----------------
charles-zablit wrote:

I had wrong assumptions: I thought the pipe would be cleared by another handler, that's clearly not the case.

I rewrote the logic to filter out non text inputs by consuming them, and then consume those inputs with `ReadFile`.

In https://github.com/llvm/llvm-project/pull/175812#discussion_r2690205275 I did not filter out the 2 properly.

This fixes the issue and does not put lldb in a busy loop anymore.


https://github.com/llvm/llvm-project/pull/175812


More information about the lldb-commits mailing list