[PR #15298] [MERGED] Make conhost act in VtIo mode earlier in startup #30571

Open
opened 2026-01-31 09:41:37 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/15298
Author: @zadjii-msft
Created: 5/5/2023
Status: ✅ Merged
Merged: 5/10/2023
Merged by: @zadjii-msft

Base: main ← Head: dev/migrie/b/15245-defterm-crashes-openconsole


📝 Commits (2)

  • 49768aa Make conhost act in VtIo mode earlier in startup
  • c42f5f1 unused

📊 Changes

2 files changed (+3 additions, -6 deletions)

View changed files

📝 src/host/VtIo.cpp (+3 -5)
📝 src/host/VtIo.hpp (+0 -1)

📄 Description

We need to act like a ConPTY just a little earlier in startup. My relevant notes start here: https://github.com/microsoft/terminal/issues/15245#issuecomment-1536150388.

Basically, we'd create the first screen buffer with 9001 rows, because it would be created before VtIo would be in a state to say "yes, we're a conpty". Then, if a CLI app emits an entire screenful of text before the terminal has a chance to resize the conpty, then the conpty will explode during _DoLineFeed. That method is absolutely not expecting the buffer to get resized (and the old text buffer deallocated).

Instead, this will treat the console as in ConPty mode as soon as VtIo::Initialize is called (this is during ConsoleCreateIoThread, which is right at the end of ConsoleEstablishHandoff, which is before the API server starts to process the client connect message). THEORETICALLY, VtIo could Initialize then fail to create objects in CreateIoHandlers (which is what we used to treat as the moment that we were in conpty mode). However, if we do fail out of CreateIoHandlers, then the console itself will fail to start up, and just die. So I don't think that's needed.

This fixes #15245. I think this is PROBABLY also the solution to #14512, but I'm not gonna explicitly mark closed. We'll loop back on it.

TODO

  • I want to audit the uses of CONSOLE_INFORMATION::IsInVtIoMode before I commit to this.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/15298 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 5/5/2023 **Status:** ✅ Merged **Merged:** 5/10/2023 **Merged by:** [@zadjii-msft](https://github.com/zadjii-msft) **Base:** `main` ← **Head:** `dev/migrie/b/15245-defterm-crashes-openconsole` --- ### 📝 Commits (2) - [`49768aa`](https://github.com/microsoft/terminal/commit/49768aaf8a31c0f0d19008e16f0eca7581a3b3c2) Make conhost act in VtIo mode earlier in startup - [`c42f5f1`](https://github.com/microsoft/terminal/commit/c42f5f1ecb2185261bcf85394fc5380b31aeb2cb) unused ### 📊 Changes **2 files changed** (+3 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/host/VtIo.cpp` (+3 -5) 📝 `src/host/VtIo.hpp` (+0 -1) </details> ### 📄 Description We need to act like a ConPTY just a little earlier in startup. My relevant notes start here: https://github.com/microsoft/terminal/issues/15245#issuecomment-1536150388. Basically, we'd create the first screen buffer with 9001 rows, because it would be created _before_ VtIo would be in a state to say "yes, we're a conpty". Then, if a CLI app emits an entire screenful of text _before_ the terminal has a chance to resize the conpty, then the conpty will explode during `_DoLineFeed`. That method is absolutely not expecting the buffer to get resized (and the old text buffer deallocated). Instead, this will treat the console as in ConPty mode as soon as `VtIo::Initialize` is called (this is during `ConsoleCreateIoThread`, which is right at the end of `ConsoleEstablishHandoff`, which is before the API server starts to process the client connect message). THEORETICALLY, `VtIo` could `Initialize` then fail to create objects in `CreateIoHandlers` (which is what we used to treat as the moment that we were in conpty mode). However, if we do fail out of `CreateIoHandlers`, then the console itself will fail to start up, and just die. So I don't think that's needed. This fixes #15245. I think this is PROBABLY also the solution to #14512, but I'm not gonna explicitly mark closed. We'll loop back on it. #### TODO * [x] I want to audit the uses of `CONSOLE_INFORMATION::IsInVtIoMode` before I commit to this. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:41:37 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30571