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>
This commit is contained in:
Dustin L. Howett
2026-06-22 18:09:00 -05:00
committed by GitHub
parent d288fa09d6
commit 05b613cf06
4 changed files with 12 additions and 2 deletions

View File

@@ -1139,7 +1139,7 @@ nullopts
NUMSCROLL
NUnit
nupkg
NVIDIA
nvidia
NVT
OACR
ocolor

View File

@@ -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();

View File

@@ -32,6 +32,7 @@ Abstract:
#include <shellscalingapi.h>
#include <windowsx.h>
#include <ShObjIdl.h>
#include <shlobj_core.h>
// Manually include til after we include Windows.Foundation to give it winrt superpowers
#define BLOCK_TIL

View File

@@ -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": [