From 05b613cf06c5169fbbcbb40644568fd6d03ea2b5 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Mon, 22 Jun 2026 18:09:00 -0500 Subject: [PATCH] Pre-warm SHGetKnownFolder to avoid a deadlock in the nvidia driver (#20351) The nvidia driver attempts to use SHGetKnownFolder (which has its own lock!) under the loader lock, which occasionally triggers a deadlock when we attempt to do the same thing during settings load. Closes #20350 (superseded) Closes #20348 Co-authored-by: gleb <46842077+groovg@users.noreply.github.com> --- .github/actions/spelling/expect/expect.txt | 2 +- src/cascadia/WindowsTerminal/WindowEmperor.cpp | 9 +++++++++ src/cascadia/WindowsTerminal/pch.h | 1 + src/host/ft_host/testmd.definition | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/actions/spelling/expect/expect.txt b/.github/actions/spelling/expect/expect.txt index e93e898c01..2fd76fc989 100644 --- a/.github/actions/spelling/expect/expect.txt +++ b/.github/actions/spelling/expect/expect.txt @@ -1139,7 +1139,7 @@ nullopts NUMSCROLL NUnit nupkg -NVIDIA +nvidia NVT OACR ocolor diff --git a/src/cascadia/WindowsTerminal/WindowEmperor.cpp b/src/cascadia/WindowsTerminal/WindowEmperor.cpp index a21ad3f02e..ab9e000389 100644 --- a/src/cascadia/WindowsTerminal/WindowEmperor.cpp +++ b/src/cascadia/WindowsTerminal/WindowEmperor.cpp @@ -544,6 +544,15 @@ void WindowEmperor::HandleCommandlineArgs(int nCmdShow) __assume(false); } + // !! LOAD BEARING !! + // This prevents loader lock contention with some versions of the nvidia + // driver, which calls SHGetKnownFolderPath triggering a delay load while + // under lock during application startup. See GH#20348. + { + wil::unique_cotaskmem_string localAppDataFolder; + SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &localAppDataFolder); + } + _app = winrt::TerminalApp::App{}; _app.Logic().ReloadSettings(); diff --git a/src/cascadia/WindowsTerminal/pch.h b/src/cascadia/WindowsTerminal/pch.h index 2b48aae8c9..10640ef474 100644 --- a/src/cascadia/WindowsTerminal/pch.h +++ b/src/cascadia/WindowsTerminal/pch.h @@ -32,6 +32,7 @@ Abstract: #include #include #include +#include // Manually include til after we include Windows.Foundation to give it winrt superpowers #define BLOCK_TIL diff --git a/src/host/ft_host/testmd.definition b/src/host/ft_host/testmd.definition index 3adef43b83..27b0545090 100644 --- a/src/host/ft_host/testmd.definition +++ b/src/host/ft_host/testmd.definition @@ -30,7 +30,7 @@ "Plugins": [ { "Type": "Microsoft.TestInfrastructure.UniversalTest.TestMD.Plugins.Etw.EtwPlugin", - "Name": "Collecting conhost logs during FTs", + "Name": "Collecting conhost logs during feature tests", "Parameters": { "$schema": "Microsoft.TestInfrastructure.UniversalTest.TestMD.Plugins.Etw.EtwPlugin-1.json", "Profiles": [