Skip to content

initialise lib_status on all failure paths in loader_scanned_icd_add - #2032

Merged
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:icd-add-lib-status-init
Sep 9, 2026
Merged

initialise lib_status on all failure paths in loader_scanned_icd_add#2032
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:icd-add-lib-status-init

Conversation

@aizu-m

@aizu-m aizu-m commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Chasing the recent lib_status work, I looked at how loader_icd_scan picks its rejection diagnostic:

loader/loader.c:4198   enum loader_layer_library_status lib_status;   // uninitialised
loader/loader.c:4200   loader_scanned_icd_add(..., &lib_status);
loader/loader.c:4205   switch (lib_status) { ... }                    // no default

loader_scanned_icd_add only writes *lib_status on some of the paths that return VK_ERROR_INCOMPATIBLE_DRIVER. Four of them do not:

:2145  NULL filename guard
:2232  missing vkCreateInstance (deprecated v0 branch)
:2241  missing vkEnumerateInstanceExtensionProperties (v0 dlsym)
:2268  missing vkEnumerateInstanceExtensionProperties (via vk_icdGetInstanceProcAddr)

A driver whose library loads but omits one of those entrypoints reaches one of these paths, and the caller then switches on an indeterminate value. The sibling paths were given a *lib_status just now, so this is a read of genuinely uninitialised stack rather than a stale-but-valid status, and the switch has no default to catch it.

Seed the out-parameter at entry so every return path leaves it defined. The specific paths still override it, so their diagnostics are unchanged.

The layer side is fine, its lib_status is a field of a calloc'd loader_layer_properties.

@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.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 111862.

@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.

Those failure paths should probably set lib_status (with a unique error code). I know I didn't add them in the recent PR because I didn't want to go out of scope for the PR.

Initializing lib_status is a much better long term solution regardless so appreciate the PR!

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3753 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3753 passed.

@charles-lunarg
charles-lunarg merged commit 6460bd6 into KhronosGroup:main Sep 9, 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