Skip to content

Query the newest DLL first in the Windows already-loaded check - #2502

Open
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:pathfinder-windows-already-loaded-order
Open

Query the newest DLL first in the Windows already-loaded check#2502
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:pathfinder-windows-already-loaded-order

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown

windows_dlls is tabulated oldest-first, and the other entry points reverse it "to achieve new -> old search order":

  • load_dl_windows.load_with_system_search()for dll_name in reversed(desc.windows_dlls)
  • load_dl_linux.check_if_already_loaded_from_elsewhere() and load_with_system_search() — both via _candidate_sonames(), which reverses

load_dl_windows.check_if_already_loaded_from_elsewhere() iterates forward instead. For a library present in more than one version it reports the oldest already-loaded one, while the system search on the same platform — and both paths on Linux — prefer the newest. Since the already-loaded check runs first in load_nvidia_dynamic_lib, that is the version the caller ends up with.

The new test is Windows-only, and deliberately so: load_dl_windows does import ctypes.wintypes and raises RuntimeError if ctypes.windll is missing, both at module scope, so it cannot be imported on other platforms at all. It stubs kernel32.GetModuleHandleW to record the probe order and asserts newest-first. On Linux it is collected and skipped — I confirmed that on a Linux runner: 1276 passed with skips going 4 → 5, no collection error. I have no Windows machine, so the assertion itself has only run in my head; the symmetry with load_with_system_search() 25 lines below is the real argument.

This pairs with #2499, which fixes the one catalog entry whose linux_sonames were tabulated in the wrong order. That one is a data fix, this one is a code fix; they are independent.

NOTE: developed with the assistance of an AI coding agent. The new test carries @pytest.mark.agent_authored per AGENTS.md. I reviewed and verified the change before submitting.

`windows_dlls` is tabulated oldest-first, and every other entry point
reverses it "to achieve new -> old search order":
`load_with_system_search()` on Windows, and both
`check_if_already_loaded_from_elsewhere()` and `load_with_system_search()`
on Linux, which share `_candidate_sonames()`.

The Windows `check_if_already_loaded_from_elsewhere()` iterates
`desc.windows_dlls` forward instead. For a library present in more than one
version it therefore reports the oldest already-loaded one, while the system
search on the same platform, and both paths on Linux, prefer the newest.
Since the already-loaded check runs first, that is the version callers get.

The new test is Windows-only: `load_dl_windows` imports `ctypes.wintypes`
and requires `ctypes.windll` at module scope, so it cannot be imported at
all on other platforms.
@copy-pr-bot

copy-pr-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.pathfinder Everything related to the cuda.pathfinder module label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.pathfinder Everything related to the cuda.pathfinder module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant