TermControl._InitializeTerminal() gives Renderer an uninitialized RenderThread then calls into Renderer. Cleanup needed? #1249

Closed
opened 2026-01-30 22:20:11 +00:00 by claunia · 3 comments
Owner

Originally created by @metathinker on GitHub (May 22, 2019).

Not really sure if there's any significance to this or what if any real bugs it's hiding, but AppVerifier is great for finding hidden bugs in my experience, so with apologies I'd suggest this is worth looking into.

Environment and reproduction steps:
Windows 10 ver. 1903 (Version 10.0.18362.116)
WinTerm built from sources @ 6c7dfd2ce4 (master as of May 21, 2019, end of business day)
Application Verifier from Windows SDK for Windows 10 ver. 1903 (SDK 10.0.18362.0)

  1. Build Windows Terminal if needed, using the release build, and deploy it using Visual Studio.
  2. Set up AppVerifier with "Basics" settings for WindowsTerminal.exe
  3. Start Windows Terminal under a debugger.

Results:
Before Windows Terminal fully starts up, observe 2 AppVerifier breaks. Both of these are in code paths wherein TermControl::_InitializeTerminal() calls into Renderer.

From my debugging, it appears that the cause is that TermControl is trying to make calls into Renderer after giving it a RenderThread but before actually initializing that RenderThread. It's not clear to me why TermControl does so much before getting around to initializing the RenderThread, but I'm not familiar with the code as is.

Fuller details here:
https://gist.github.com/metathinker/33d8cf0f191e92176f4f9852927f7e54

Originally created by @metathinker on GitHub (May 22, 2019). Not really sure if there's any significance to this or what if any real bugs it's hiding, but AppVerifier is great for finding hidden bugs in my experience, so with apologies I'd suggest this is worth looking into. **Environment and reproduction steps:** Windows 10 ver. 1903 (`Version 10.0.18362.116`) WinTerm built from sources @ 6c7dfd2ce45841d32f3990147506de2f7903485d (master as of May 21, 2019, end of business day) [Application Verifier](https://docs.microsoft.com/windows-hardware/drivers/debugger/application-verifier) from Windows SDK for Windows 10 ver. 1903 (SDK 10.0.18362.0) 1. Build Windows Terminal if needed, using the release build, and deploy it using Visual Studio. 2. Set up AppVerifier with "Basics" settings for `WindowsTerminal.exe` 3. Start Windows Terminal under a debugger. **Results:** Before Windows Terminal fully starts up, observe 2 AppVerifier breaks. Both of these are in code paths wherein `TermControl::_InitializeTerminal()` calls into `Renderer`. From my debugging, it appears that the cause is that `TermControl` is trying to make calls into `Renderer` after giving it a `RenderThread` but before actually initializing that `RenderThread`. It's not clear to me why `TermControl` does so much before getting around to initializing the `RenderThread`, but I'm not familiar with the code as is. Fuller details here: https://gist.github.com/metathinker/33d8cf0f191e92176f4f9852927f7e54
Author
Owner

@zadjii-msft commented on GitHub (May 22, 2019):

Huh. I don't see any commentary on why THROW_IF_FAILED(localPointerToThread->Initialize(_renderer.get())); is called so much later, so there probably isn't a reason TBH. That could probably be moved without too much trouble.

@zadjii-msft commented on GitHub (May 22, 2019): Huh. I don't see any commentary on why `THROW_IF_FAILED(localPointerToThread->Initialize(_renderer.get()));` is called so much later, so there probably isn't a reason TBH. That could probably be moved without too much trouble.
Author
Owner

@metathinker commented on GitHub (May 22, 2019):

It seems especially strange to me that the TermControl is giving its Renderer an uninitialized RenderThread anyway - no object should give another object an uninitialized anything. I'd need to study what initialization tasks the RenderThread does to know more.

@metathinker commented on GitHub (May 22, 2019): It seems especially strange to me that the TermControl is giving its Renderer an uninitialized RenderThread anyway - no object should give another object an uninitialized anything. I'd need to study what initialization tasks the RenderThread does to know more.
Author
Owner

@DHowett-MSFT commented on GitHub (May 23, 2019):

I'm marking this triaged as it's a legit bug. Thanks for the report!

@DHowett-MSFT commented on GitHub (May 23, 2019): I'm marking this triaged as it's a legit bug. Thanks for the report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1249