Skip to content

clamp re-queried counts in terminator_EnumeratePhysicalDeviceGroups#1942

Open
aizu-m wants to merge 1 commit into
KhronosGroup:mainfrom
aizu-m:phys-dev-groups-count-clamp
Open

clamp re-queried counts in terminator_EnumeratePhysicalDeviceGroups#1942
aizu-m wants to merge 1 commit into
KhronosGroup:mainfrom
aizu-m:phys-dev-groups-count-clamp

Conversation

@aizu-m

@aizu-m aizu-m commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Tracing the device-group terminator while chasing a stack-smash report:

loader.c:7829  for (indiv_gpu = 0; indiv_gpu < count_this_time; ++indiv_gpu)
                   local_phys_dev_groups[indiv_gpu + cur_icd_group_count] = ...

local_phys_dev_groups is sized to total_count, which is summed in the first pass that asks each ICD for its group count. The fill pass then re-queries every ICD into count_this_time (EnumeratePhysicalDevices on the no-device-group path, EnumeratePhysicalDeviceGroups otherwise, both with a NULL property pointer) and indexes the array by that value. The re-queried count is never bounded to the space left in the array.

So a driver that reports more devices on the second query than it did on the first walks off the end of the stack array. Both fill branches re-query, so both can overrun. Same count-drift behaviour the *2KHR emulators already guard against, here on the two-pass group path.

Clamp count_this_time to the remaining reserved space (total_count - cur_icd_group_count) right after each re-query. No change for a well-behaved driver where the two passes agree; the existing device-group tests stay green.

@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