Skip to content

skip malformed entries in parse_device_configurations#1979

Open
aizu-m wants to merge 1 commit into
KhronosGroup:mainfrom
aizu-m:device-config-skip-malformed
Open

skip malformed entries in parse_device_configurations#1979
aizu-m wants to merge 1 commit into
KhronosGroup:mainfrom
aizu-m:device-config-skip-malformed

Conversation

@aizu-m

@aizu-m aizu-m commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Chasing why a valid device_configuration silently vanished, I put one good entry in front of a malformed one in vk_loader_settings.json and watched the enumerate call:

vkEnumeratePhysicalDevices reported 0 physical devices
(expected 1, the device whose deviceUUID matched the good entry)

parse_device_configurations in loader/settings.c sets device_configuration_count to the JSON array size before the loop, then uses continue to skip entries that fail to parse. Two things go wrong from there.

The count is never lowered to the number of entries that actually parsed, so skipped slots stay zero-initialised yet are still walked later by loader_apply_settings_device_configurations. And a skipped entry leaves res at VK_ERROR_INITIALIZATION_FAILED, so when the malformed entry happens to be the last one, the cleanup at out: frees the whole array and zeroes the count, taking the valid entries with it. The count query in terminator_EnumeratePhysicalDevices then reports 0.

The settings file is untrusted input, so one trailing typo empties the device list.

Reset res in the skip path so a bad entry no longer poisons the good ones, and set the count to the number that parsed. Behaviour for all-valid files is unchanged. Regression test added to loader_settings_tests.cpp.

@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

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.

2 participants