Skip to content

Skip manifests already found when scanning search paths - #2033

Merged
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
Wint3rNight:fix-duplicate-icd-dedup
Sep 18, 2026
Merged

charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
Wint3rNight:fix-duplicate-icd-dedup

Conversation

@Wint3rNight

@Wint3rNight Wint3rNight commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Duplicate elimination runs on the search path strings, so it does not catch the case where one path names a directory and another names a file inside that directory. The two strings differ, but the directory scan and the explicit file path resolve to the same manifest, so the driver is loaded twice and its physical devices are reported twice.

With VK_DRIVER_FILES set to a folder plus two manifests inside that folder, vkEnumeratePhysicalDevices reports 9 devices where 5 exist, matching the log in the issue:

Original order:
      [0] pd10   [1] pd11   [2] pd00   [3] pd01
      [4] pd10   [5] pd11   [6] pd00   [7] pd01
      [8] pd0

Both call sites in add_data_files resolve to a full path before calling add_if_manifest_file, so comparing the resolved name catches the repeat. The existing copy_str_to_string_list_if_unique helper already does exactly this.

This is only visible with Vulkan 1.1 or newer, because GPDP2 gates the Linux physical device sort. The existing env var tests run at 1.0, which is why CI never caught it.

Added EnvVarICDOverrideSetup.DirAndFileOverlapDoesNotDuplicate, which fails on main with 9 devices and passes with the fix. Full suite is 703/703.

Two notes:

  • add_data_files also serves layer discovery, so layers get the same protection. No existing test changes behaviour.
  • loader_get_fullpath does not canonicalise symlinks or .. segments, so two different spellings of the same file are still not detected. That is outside what this issue reports and I have left it alone.

The issue also suggests running these env var cases at both 1.0 and 1.1, since much loader logic depends on GPDP2. That is a broader testing change and I have kept it out of this PR, but happy to follow up if useful.

@ci-tester-lunarg

Copy link
Copy Markdown

Author Wint3rNight not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

Author Wint3rNight not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 119687.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3766 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3766 passed.

@charles-lunarg charles-lunarg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't modify prepend_if_manifest_file() which also adds to the list, so for paths added by the loader settings file, duplicates would sail on through. That function will be more involved because 'prepending' should take precedence - so if there is a duplicate, we should still prepend while also removing the duplicate.

While I understand marking the issue as 'fixed' is to link it with #1874, I am going to remove it because the issue isn't solely about fixing duplicates, but expanding testing to cover many more cases where those duplicates may occur (due to GPDP2).

Comment thread loader/loader.c Outdated
Comment on lines +3387 to +3390
// Skip a manifest that is already in the list. The same file is reached twice whenever a search path names a
// directory and another names a file inside it, which duplicate elimination on the search paths cannot catch
// because those two strings differ. Both call sites resolve to a full path before getting here, so comparing
// the resolved name is enough to spot it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is way to long for what it is.

It also has an un-truth. While loader_get_fullpath() does attempt to create (and check) the paths given to it, it doesn't try to validate already existing paths. Which to be clear is likely an issue in its own right but not important. By claiming paths 'resolve to a full path before getting here', it tries to claim a truth about something that isn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepend_if_manifest_file now removes an existing entry before prepending, so the settings file still takes precedence without loading the driver twice. Added a settings file test for it.

Also cut the comment down to one line and dropped the claim about full paths, since loader_get_fullpath copies paths as they are.

Duplicate elimination runs on the search path strings, so it cannot
catch the case where one path names a directory and another names a
file inside that directory. The directory scan and the explicit file
path build the same string for the same manifest, so the driver is
loaded twice and its physical devices are reported twice. Skip a
manifest that is already in the list.

Drivers from the loader settings file are prepended and had the same
problem. An existing entry is now removed first, so the settings file
still takes precedence without loading the driver twice.

The duplication is only visible with Vulkan 1.1 or newer, because
GPDP2 gates the Linux physical device sort, which is why the existing
tests at 1.0 did not catch it.
@Wint3rNight
Wint3rNight force-pushed the fix-duplicate-icd-dedup branch from 5e1c8d9 to d8247fe Compare September 16, 2026 20:37
@ci-tester-lunarg

Copy link
Copy Markdown

Author Wint3rNight not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

Author Wint3rNight not on autobuild list. Waiting for curator authorization before starting CI build.

@charles-lunarg charles-lunarg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much appreciated.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 123315.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3767 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3767 passed.

@charles-lunarg
charles-lunarg merged commit 441c3d2 into KhronosGroup:main Sep 18, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants