From 12722441810317829b9605c568bbf3569a9fc7af Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Fri, 4 Sep 2026 13:32:54 -0400 Subject: [PATCH] icd: Do not clear loader environment in extension enumeration vkEnumerateInstanceExtensionProperties() only reads the cached instance extension list and does not call into the Vulkan loader, so the EnvironmentOverride taken at this entry point does not protect any downstream call. The override clears the loader environment variables for the whole process while it is held, which is visible to every thread. Because the Vulkan SC loader resolves drivers from the process environment on each pre-instance call, a driver scan issued by another thread during that window can resolve differently than it otherwise would. Removing the override here closes that window at this entry point. The override also acquires the environment mutex. No synchronization is needed for these reads: every write to instance_extension_list_ happens in the Global constructor, which completes at library load before any exported entry point can run, and the member is private with no accessor. This does not remove the window in general. The remaining EnvironmentOverride sites still modify the process environment for the duration of calls that do use the Vulkan loader. --- icd/vksc_global.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/icd/vksc_global.cpp b/icd/vksc_global.cpp index 36dc6e3..a9c0465 100644 --- a/icd/vksc_global.cpp +++ b/icd/vksc_global.cpp @@ -214,7 +214,9 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t* pApiVersion) VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties) { - icd::EnvironmentOverride override(vksc::ICD.Environment()); + // No EnvironmentOverride here: this entry point only reads the cached instance extension list and + // never calls into the Vulkan loader, so clearing the loader environment variables has no effect at + // this site, while the clearing itself is process-wide and visible to concurrent driver discovery. return vksc::ICD.EnumerateInstanceExtensionProperties(pLayerName, pPropertyCount, pProperties); }