[PR #1044] [MERGED] Guard try_query calls with a null check on the pointer we're QI-ing... #24448

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/1044
Author: @miniksa
Created: 5/28/2019
Status: Merged
Merged: 5/29/2019
Merged by: @DHowett-MSFT

Base: masterHead: miniksa-wil-com-ptr-crash


📝 Commits (1)

  • 37cb282 Guard try_query calls with a null check on the pointer we're QI-ing from as even wil::com_ptr_nothrow can still inadvertantly throw an 'access violation exception' when null pointer deref-ing (WIL won't check if it's null before attempting, CComQIPtr apparently didn't care.

📊 Changes

2 files changed (+37 additions, -23 deletions)

View changed files

📝 src/tsf/ConsoleTSF.cpp (+31 -20)
📝 src/tsf/ConsoleTSF.h (+6 -3)

📄 Description

…from as even wil::com_ptr_nothrow can still inadvertantly throw an 'access violation exception' when null pointer deref-ing (WIL won't check if it's null before attempting, CComQIPtr apparently didn't care.

PR Checklist

  • Closes Build Fails on 1H20 Insider Preview with VS2017 or VS2019 (#1037)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #1037

Detailed Description of the Pull Request / Additional comments

This failed inside internal stress gates in scenarios where the TSF couldn't be stood up. The Uninitialize method gets called and attempts to QI things while unregistering and tearing down. The old CComQIPtr apparently tolerated QI-ing a null into something as a null without an issue. the wil::com_ptr_nothrow apparently blindly dereferences the given pointer and "throws" an access violation.

Theoretically, this might be something to upstream to https://github.com/microsoft/wil... but we need to fix the gate failure ASAP.


🔄 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/1044 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 5/28/2019 **Status:** ✅ Merged **Merged:** 5/29/2019 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `miniksa-wil-com-ptr-crash` --- ### 📝 Commits (1) - [`37cb282`](https://github.com/microsoft/terminal/commit/37cb2823c02a6d68d8015fb235f58859ad677995) Guard try_query calls with a null check on the pointer we're QI-ing from as even wil::com_ptr_nothrow can still inadvertantly throw an 'access violation exception' when null pointer deref-ing (WIL won't check if it's null before attempting, CComQIPtr apparently didn't care. ### 📊 Changes **2 files changed** (+37 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `src/tsf/ConsoleTSF.cpp` (+31 -20) 📝 `src/tsf/ConsoleTSF.h` (+6 -3) </details> ### 📄 Description …from as even wil::com_ptr_nothrow can still inadvertantly throw an 'access violation exception' when null pointer deref-ing (WIL won't check if it's null before attempting, CComQIPtr apparently didn't care. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #1037 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [x] Requires documentation to be updated * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #1037 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments This failed inside internal stress gates in scenarios where the TSF couldn't be stood up. The `Uninitialize` method gets called and attempts to QI things while unregistering and tearing down. The old `CComQIPtr` apparently tolerated QI-ing a null into something as a null without an issue. the `wil::com_ptr_nothrow` apparently blindly dereferences the given pointer and "throws" an access violation. Theoretically, this might be something to upstream to https://github.com/microsoft/wil... but we need to fix the gate failure ASAP. --- <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:03:23 +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#24448