Repository navigation
Conversation
Paravirtualized adapters, e.g. NVIDIA GRID vGPU on VMware, may not report a physical device ID. The gpu collector then looks up PCI\VEN_0000&DEV_0000 in cfgmgr32. If no device matches, CM_Get_Device_ID_List_Size can return a size of 0, and CMGetDeviceIDList indexed the empty buffer, which panicked during Build. Return no devices for an empty list, and let the cfgmgr32 wrappers return an error for an empty buffer or a device instance ID without a NUL terminator. getDevice now passes a NUL-terminated copy of the ID to CM_Locate_DevNodeW instead of relying on the terminator that follows the slice in the list buffer. Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Windows may return an error instead of an empty list for a device ID that doesn't exist. Assert that the lookup doesn't panic and returns no devices, and log the size reported by CM_Get_Device_ID_List_SizeW. Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Joe · project thread
What this PR does / why we need it
Paravirtualized adapters, e.g. NVIDIA GRID vGPU on a VMware VM, may not report a physical device ID (
KMTQAITYPE_PHYSICALADAPTERDEVICEIDSreturnsERROR_FILE_NOT_FOUND, whichgdi32tolerates). The gpu collector then looks upPCI\VEN_0000&DEV_0000&...in cfgmgr32. When nothing matches,CM_Get_Device_ID_List_Sizecan report a size of 0, andCMGetDeviceIDListtook&buf[0]of the empty buffer, which panics with index out of range duringBuild.GetDevicesInstanceIDsreturns no devices for an empty list. The gpu collector then falls back to the gdi32 device ID, as it already does when no PnP instance matches.CMGetDeviceIDListreturnsErrEmptyBufferfor an empty buffer, andCMLocateDevNodereturnsErrInvalidDeviceIDfor an empty or not NUL-terminated ID, instead of indexing it.getDevicepasses a NUL-terminated copy of the instance ID toCM_Locate_DevNodeW. Before, it relied on the NUL that happens to follow the slice returned byParseMultiSzin the list buffer.Embedders that don't recover panics in
Build(Grafana Alloy 1.12.x pins v0.31.3) crash on this and restart in a loop, without logs because the trace goes to stderr: grafana/alloy#7678. windows_exporter itself on main already recovers panics inBuildandCollect, so it would only report the gpu collector as failed.Which issue this PR fixes
None in this repository.
Special notes for your reviewer
The root cause comes from reading the code, not from a reproduction on a vGPU host. The new
TestGetDevicesInstanceIDsNoMatchruns the lookup forPCI\VEN_0000&DEV_0000&SUBSYS_00000000&REV_00on the Windows CI runner.Particularly user-facing changes
The gpu collector no longer fails (or crashes embedders) on adapters without a PCI device ID.
Checklist
Generated by Claude Code