Skip to content

Commit 270be80

Browse files
aryanputtarwgk
andauthored
fix(pathfinder): remove dead/misleading error handling in platform loaders (#2239)
* fix(pathfinder): remove dead/misleading error handling in platform loaders Two dead error-handling paths in the dynamic-lib platform loaders: - load_dl_linux.load_with_system_search guarded abs_path with 'if abs_path is None: raise RuntimeError("No expected symbol ...")'. abs_path_for_dynamic_library never returns None (it returns a resolved path or raises OSError), so the branch is unreachable and its message is factually wrong (it concerns dlinfo path resolution, not symbols). Drop the dead branch and let the descriptive OSError surface, matching the deterministic-loader policy of not masking discovery/load failures. - load_dl_windows.add_dll_directory had 'if not result: pass', a no-op; the PATH update below already runs unconditionally. Remove the dead branch and clarify the comment on why PATH is updated regardless. No behavior change: both removed branches were unreachable or no-ops. Signed-off-by: Aryan <aryansputta@gmail.com> * fix(pathfinder): simplify loader review comments --------- Signed-off-by: Aryan <aryansputta@gmail.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
1 parent bdd6447 commit 270be80

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ def load_with_system_search(desc: LibDescriptor) -> LoadedDL | None:
164164
Returns:
165165
A LoadedDL object if successful, None if the library cannot be loaded
166166
167-
Raises:
168-
RuntimeError: If the library is loaded but no expected symbol is found
169167
"""
170168
for soname in _candidate_sonames(desc):
171169
try:
@@ -174,8 +172,7 @@ def load_with_system_search(desc: LibDescriptor) -> LoadedDL | None:
174172
pass
175173
else:
176174
abs_path = abs_path_for_dynamic_library(desc.name, handle)
177-
if abs_path is None:
178-
raise RuntimeError(f"No expected symbol for libname={desc.name!r}")
175+
assert abs_path
179176
return LoadedDL(abs_path, False, handle._handle, "system-search")
180177
return None
181178

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_windows.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ def add_dll_directory(dll_abs_path: str) -> None:
6969
dirpath = os.path.dirname(dll_abs_path)
7070
assert os.path.isdir(dirpath), dll_abs_path
7171

72-
# Add the DLL directory to the search path
73-
result = kernel32.AddDllDirectory(dirpath)
74-
if not result:
75-
# Fallback: just update PATH if AddDllDirectory fails
76-
pass
72+
# Add the DLL directory to the native search path. AddDllDirectory only
73+
# affects the LOAD_LIBRARY_SEARCH_USER_DIRS search; PATH is updated
74+
# unconditionally below to also cover legacy dependent-DLL resolution.
75+
kernel32.AddDllDirectory(dirpath)
7776

7877
# Update PATH as a fallback for dependent DLL resolution
7978
curr_path = os.environ.get("PATH")

0 commit comments

Comments
 (0)