[rocprofiler-compute] [Bugfix:] Handle native tool path detection gracefully#3501
Conversation
This fixes the issue where the standalone binary does not run if at least three parent directories are not available in cwd With this change, we will be gracefully handling such issues instead of crashing.
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug where the rocprofiler-compute standalone binary would crash when run from a directory with fewer than three parent directories (e.g., running from /root or /tmp). The issue occurred during native tool path detection, which attempted to access script_path.parents[2] without checking if that many parent directories exist.
Changes:
- Added length check before accessing
script_path.parents[2]to prevent IndexError - Falls back to
Path()(current directory) when fewer than 3 parent directories exist - Gracefully handles path detection failure through existing try-except error handling
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_base.py
Show resolved
Hide resolved
xuchen-amd
left a comment
There was a problem hiding this comment.
Tested locally - works.
Do we have test coverage for this?
We don't have any unit tests for run_profiling function to test this behavior. |
|
preivous passing psdb: http://rocm-ci.amd.com/job/compute-rocm-dkms-systems-psdb/14996/ |
…cefully (#3501) * Bugfix: Handle native tol path detection gracefully This fixes the issue where the standalone binary does not run if at least three parent directories are not available in cwd With this change, we will be gracefully handling such issues instead of crashing. * Address review comments
Motivation
Handle native tool path detection gracefully
Technical Details
This fixes the issue where the standalone binary does not run if at least three parent directories are not available in cwd
With this change, we will be gracefully handling such issues instead of crashing.
JIRA ID
Test Plan
Create standalone binary with this PR and try to run it from /root and ensure no crash
Test Result
Tests pass
Submission Checklist