[PR #10238] [MERGED] Prevent crashes in Settings UI launch on OS versions before package management extensions #27959

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10238
Author: @miniksa
Created: 5/27/2021
Status: Merged
Merged: 5/27/2021
Merged by: @undefined

Base: mainHead: dev/miniksa/def_set_crash


📝 Commits (1)

  • ef61901 Log not return errors from looking up consoles/terminals because the default conhost is always returned as one element. Change the model to hold a nullptr DefaultTerminal model representation even if that fails because XAML is A-OK with nullptr and will select no item as Current but will crash out if it gets an exception.

📊 Changes

3 files changed (+11 additions, -5 deletions)

View changed files

📝 src/cascadia/TerminalSettingsModel/DefaultTerminal.cpp (+5 -2)
📝 src/cascadia/TerminalSettingsModel/DefaultTerminal.h (+1 -1)
📝 src/propslib/DelegationConfig.cpp (+5 -2)

📄 Description

Prevent crashes in Settings UI launch on OS versions before package management extensions

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • On older OS versions like 18363, some of the COM interfaces we use to look up information from the OS application package management catalog (to find default terminals) are unavailable. This returns E_NOINTERFACE. This then ends up returning an empty list of items and null as a selected item.
  • I had intended for that to not return that particular error all the way up and just log it because the console and terminal lookup functions always return at least one element: the one representing the conhost.exe that is already on the machine.
  • I have changed the "default packages" lookup to log instead of return failures like E_NOINTERFACE such that it can continue processing and make the "package" of the hardcoded conhost.exe default no matter what. (It will still return an error if there are somehow 0 packages because that code changed or some other catastrophic event happened...)
  • I have also changed the Model to have a nulled DefaultTerminal model object (as all winrt objects are nullable) instead of using an optional. I did this because XAML is perfectly happy receiving a nullptr for a selected item and will just not select anything. By contrast, if it has an exception occur... it will just bubble that out and crash.

Validation Steps Performed

  • Simulated no items returned from list and nullptr returned to XAML on Current() method of Model. Validated XAML will happily select no item from list (and is fine with an empty list of items... that is it doesn't crash).
  • Simulated downlevel OS returning package management errors in lookup catalog functions after the hardcoded default is added to the list. Ensured that this error is only logged, the remainder of the package identification functions make the hardcoded default package, and it is presented as your one and only option in the XAML.

🔄 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/10238 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 5/27/2021 **Status:** ✅ Merged **Merged:** 5/27/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/miniksa/def_set_crash` --- ### 📝 Commits (1) - [`ef61901`](https://github.com/microsoft/terminal/commit/ef61901a02fe564929be63fd36d479e494b16411) Log not return errors from looking up consoles/terminals because the default conhost is always returned as one element. Change the model to hold a nullptr DefaultTerminal model representation even if that fails because XAML is A-OK with nullptr and will select no item as Current but will crash out if it gets an exception. ### 📊 Changes **3 files changed** (+11 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalSettingsModel/DefaultTerminal.cpp` (+5 -2) 📝 `src/cascadia/TerminalSettingsModel/DefaultTerminal.h` (+1 -1) 📝 `src/propslib/DelegationConfig.cpp` (+5 -2) </details> ### 📄 Description Prevent crashes in Settings UI launch on OS versions before package management extensions ## PR Checklist * [x] Closes #10106 * [x] I work here * [x] Manual tests passed. ## Detailed Description of the Pull Request / Additional comments - On older OS versions like 18363, some of the COM interfaces we use to look up information from the OS application package management catalog (to find default terminals) are unavailable. This returns `E_NOINTERFACE`. This then ends up returning an empty list of items and null as a selected item. - I had intended for that to not return that particular error all the way up and just log it because the console and terminal lookup functions always return at least one element: the one representing the `conhost.exe` that is already on the machine. - I have changed the "default packages" lookup to log instead of return failures like E_NOINTERFACE such that it can continue processing and make the "package" of the hardcoded `conhost.exe` default no matter what. (It will still return an error if there are somehow 0 packages because that code changed or some other catastrophic event happened...) - I have also changed the Model to have a nulled DefaultTerminal model object (as all winrt objects are nullable) instead of using an optional. I did this because XAML is perfectly happy receiving a `nullptr` for a selected item and will just not select anything. By contrast, if it has an exception occur... it will just bubble that out and crash. ## Validation Steps Performed - Simulated no items returned from list and nullptr returned to XAML on Current() method of Model. Validated XAML will happily select no item from list (and is fine with an empty list of items... that is it doesn't crash). - Simulated downlevel OS returning package management errors in lookup catalog functions after the hardcoded default is added to the list. Ensured that this error is only logged, the remainder of the package identification functions make the hardcoded default package, and it is presented as your one and only option in the XAML. --- <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:25:24 +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#27959