-
Notifications
You must be signed in to change notification settings - Fork 245
feat(pathfinder): add CTK root canary probe for non-standard-path libs #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cpcloud
wants to merge
9
commits into
NVIDIA:main
Choose a base branch
from
cpcloud:nvvm-discovery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6c8ea7a
feat(pathfinder): add CTK root canary probe for non-standard-path libs
cpcloud 44c0abd
style(pathfinder): update copyright header date in test file
cpcloud e6f60a4
refactor(pathfinder): use pytest-mock instead of unittest.mock in tests
cpcloud 571d71d
chore: fix typing
cpcloud 905862d
fix(pathfinder): make CTK root discovery tests platform-aware
cpcloud 8091a6e
chore: style
cpcloud 3462410
fix(pathfinder): normalize paths from _find_lib_dir_using_anchor_point
cpcloud 5eb7304
refactor(pathfinder): isolate CTK canary probe in subprocess
cpcloud 442acb2
fix(pathfinder): satisfy pre-commit typing for canary probe
cpcloud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
cuda_pathfinder/cuda/pathfinder/_dynamic_libs/canary_probe_subprocess.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env python | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import json | ||
| import sys | ||
|
|
||
| from cuda.pathfinder._dynamic_libs.load_dl_common import LoadedDL | ||
| from cuda.pathfinder._utils.platform_aware import IS_WINDOWS | ||
|
|
||
| if IS_WINDOWS: | ||
| from cuda.pathfinder._dynamic_libs.load_dl_windows import load_with_system_search | ||
| else: | ||
| from cuda.pathfinder._dynamic_libs.load_dl_linux import load_with_system_search | ||
|
|
||
|
|
||
| def _probe_canary_abs_path(libname: str) -> str | None: | ||
| loaded: LoadedDL | None = load_with_system_search(libname) | ||
| if loaded is None: | ||
| return None | ||
| abs_path = loaded.abs_path | ||
| if not isinstance(abs_path, str): | ||
| return None | ||
| return abs_path | ||
|
|
||
|
|
||
| def main(argv: list[str] | None = None) -> int: | ||
| args = sys.argv[1:] if argv is None else argv | ||
| if len(args) != 1: | ||
| return 2 | ||
| print(json.dumps(_probe_canary_abs_path(args[0]))) # noqa: T201 | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working on the initial version of pathfinder, using
subprocesswas frowned upon, for general security reasons I think, so I implemented cuda_pathfinder/tests/spawned_process_runner.py. I was hoping you'd use that here.The rest looks good to me, although I still need to spend some time carefully looking at the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spawned_process_runner.py came from here (from before we had Cursor):
https://chatgpt.com/share/681914ce-f274-8008-9e9f-4538716b4ed7
There I started with:
So I think spawned_process_runner.py will give us better isolation (and predictability), it's not just the secops concern.