Skip to content

Fix ASan runtime discovery and component loader paths - #8721

Merged
sa-faizal merged 3 commits into
mainfrom
users/safaizal/asan-runtime-discovery-20261003
Oct 8, 2026
Merged

sa-faizal merged 3 commits into
mainfrom
users/safaizal/asan-runtime-discovery-20261003

Conversation

@sa-faizal

@sa-faizal sa-faizal commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Host-ASan tests fail before execution because the runtime directory is missing from LD_LIBRARY_PATH, while HIP and rocprofiler-sdk launchers query only the older architecture-suffixed filename.

Export the runtime directory and reuse the validated configured runtime or shared discovery fallback, supporting current and legacy filenames. This addresses loader failures in rocPRIM/hipCUB/rocThrust resource helpers and TensileLite's rocisa import. Existing tests are reused; no test methods are added.

Validation:

  • All 17 existing configuration/dashboard tests passed on Linux; the 8 SDK dashboard tests also passed on Windows. The reused assertions check the runtime directory and SDK preload command. Formatting and syntax checks passed. Current Linux/Windows unit CI passed.
  • On MI325 (gfx942), configured and standalone runtime discovery passed. All three resource helpers changed from missing ASan dependencies to fully resolved ldd output. The SDK launcher generated the unsuffixed preload path and correct loader directory. No sanitizer suppressions were added.
  • Earlier component CI gets past discovery but still reports HIP/hipCUB/rocThrust faults or leaks, an SDK timeout, and a TensileLite exit without a diagnostic. Targeted validation does not establish that the complete GPU suites pass.

ISSUE ID : #7202

@therock-pr-bot

therock-pr-bot Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@sa-faizal
sa-faizal marked this pull request as ready for review October 3, 2026 19:53
@sa-faizal sa-faizal added the ci:host-asan Opt-in to running multi-arch host-asan CI on a pull request label Oct 3, 2026
@sa-faizal
sa-faizal marked this pull request as draft October 4, 2026 06:53
@sa-faizal
sa-faizal added this pull request to stack #8734 October 4, 2026 18:53
@sa-faizal
sa-faizal marked this pull request as ready for review October 8, 2026 04:37
@sa-faizal
sa-faizal removed the request for review from geomin12 October 8, 2026 04:38
@sa-faizal
sa-faizal force-pushed the users/safaizal/asan-runtime-discovery-20261003 branch from 28bc05d to 4c3d143 Compare October 8, 2026 18:56

@nunnikri nunnikri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

# Importing is_asan from amdgpu_family_matrix.py
sys.path.append(str(THEROCK_DIR / "build_tools" / "github_actions"))
from amdgpu_family_matrix import is_asan
from configure_asan_env import get_asan_runtime_path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue, just an observation. asan env is getting imported in release job also

THEROCK_DIR = SCRIPT_DIR.parent.parent.parent
sys.path.append(str(THEROCK_DIR / "build_tools" / "github_actions"))
from amdgpu_family_matrix import is_asan
from configure_asan_env import get_asan_runtime_path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue, just an observation. asan env is getting imported in release job also

@sa-faizal
sa-faizal merged commit a3d5897 into main Oct 8, 2026
209 of 210 checks passed
@sa-faizal
sa-faizal deleted the users/safaizal/asan-runtime-discovery-20261003 branch October 8, 2026 21:35
@github-project-automation github-project-automation Bot moved this from TODO to Done in TheRock Triage Oct 8, 2026
sa-faizal added a commit that referenced this pull request Oct 8, 2026
TensileLite pytest jobs can fail during startup when an imported
extension loads ASan too late. Preload the discovered runtime when
starting the pytest child, preserving existing preloads, sanitizer
settings, and the parent environment.

Reuse the existing environment-prepend test to check preload order and
parent-environment preservation; no test methods are added. This PR is
stacked on #8721 and contains only the pytest follow-up. Retarget to
`main` after that dependency lands.

Validation:

- All 45 existing pytest-runner tests passed on Linux and Windows.
Formatting and diff checks passed. [Current Linux/Windows unit CI
passed](https://github.com/ROCm/TheRock/actions/runs/37729317109).
- On **MI325 (gfx942)**, the current runner with matching [host-ASan
artifacts](https://github.com/ROCm/TheRock/actions/runs/37149900303)
collected and passed **25/25 existing timing tests**. This validates
host-side startup and timing assertions, not GPU kernel execution.
- The 25 assertions pass, but teardown exits 1 with 679,993 bytes in 587
allocations reported by LeakSanitizer. Controlled Python 3.12.3
baselines reproduce leaks from importing pytest alone (69,553 bytes) and
NumPy alone (941,456 bytes). The same 25 tests without shared
conftest/plugin loading retain only the pytest baseline. These
dependency shutdown failures remain unresolved; no sanitizer suppression
was added. [rocm-libraries
#13055](ROCm/rocm-libraries#13055) addresses the
separate isolated rocisa import leak.

ISSUE ID : #8735

*AI-assisted change.*

Fixes #8735

---------

Co-authored-by: Sahil Faizal <safaizal@amd.com>
dileepr1 added a commit that referenced this pull request Oct 13, 2026
Takes main's versions of the ASAN env helpers, which #8721 refactored
(get_asan_runtime_path, and _resolve_library_path now appends the clang
resource directory), and restores main's test_components gate: #8123
fixed the sanity LeakSanitizer failure, so the TEMPORARY !failure()
removal is no longer needed and the run reproduces production behaviour.
dileepr1 added a commit that referenced this pull request Oct 13, 2026
#8721 landed the same ASAN runtime work on main (both runtime library
names, and the clang resource directory on LD_LIBRARY_PATH), so the
older #8341 copy carried here was stale and failed 14 of its own tests
against the refactor. The branch is now exactly #8455 on current main,
which is what would run if #8455 merged.
dileepr1 added a commit that referenced this pull request Oct 13, 2026
#8721 changed ASAN runtime discovery to anchor on the artifact tree, which the
wheel tests have no equivalent of. Keep this branch's PATH-based lookup as the
generalisation of both, and re-anchor #8721's get_asan_runtime_path on it so
test_hiptests.py keeps working. test_hiptests.py itself takes main's version.

Co-authored-by: Cursor <cursoragent@cursor.com>
dileepr1 added a commit that referenced this pull request Oct 13, 2026
…iscovery

#8721 added get_asan_runtime_path for standalone launchers but no test. This
branch changes how it finds a compiler, so pin the contract its callers rely
on: an explicit ASAN_RUNTIME_PATH wins, a missing one raises, discovery works
without the toolchain on PATH, and failures surface as FileNotFoundError.

Co-authored-by: Cursor <cursoragent@cursor.com>
dileepr1 added a commit that referenced this pull request Nov 3, 2026
## Summary

Fixes #6331. `rocm-sdk test` aborts on every Linux ASAN run with `ASan
runtime does not come first in initial library list`, so the wheel test
jobs fail without executing a single test.

A process's library load order is fixed at `exec`, so nothing inside the
test can insert the ASAN runtime ahead of the interpreter; the only
lever is the environment before Python starts.
[#8123](#8123) added that preloading
but wired it into `test_component.yml` only, and `test_rocm_wheels.yml`
had no ASAN handling at all.

## What changed

- **`test_rocm_wheels.yml`** — new optional `artifact_group` input,
gated on `contains(inputs.artifact_group, 'asan')` the same way
`test_component.yml` is. Resolves the ASAN environment after each
install, because the runtime ships inside the wheels and
`rocm[profiler]` installs into its own venv, then sets `LD_PRELOAD` on
the `rocm-sdk test` steps.
- **`multi_arch_ci_linux.yml`** — passes `artifact_group` through.
- **`configure_asan_env.py`** — locates the compiler on `PATH` as well
as in an artifact tree, since these jobs `pip install` ROCm and have no
artifact tree. Both runtime spellings are handled (#8077). Exports
`LSAN_OPTIONS` pointing at the new suppressions file.
`get_asan_runtime_path()` from #8721 keeps working for standalone
launchers, now with unit tests.
- **`test_tools/lsan_suppressions.txt`** — new. Preloading also puts the
uninstrumented CPython and `/usr/bin/perl` under LeakSanitizer, which
reports their interpreter internals as leaks. These are scoped
suppressions rather than `detect_leaks=0`, so leaks in the ROCm
libraries under test still fail the job.
- **`test_component.yml`** — puts the extracted `llvm/bin` on `PATH` for
the above.

## Validation

**CI:** [run
40887799669](https://github.com/ROCm/TheRock/actions/runs/40887799669) —
`test_rocm_wheels.yml` on `gfx94X-dcgpu` against ASAN wheels, green. All
three `rocm-sdk test` steps execute and pass:

| Step | Result |
| --- | --- |
| `Test rocm[libraries]` | `Ran 19 tests` — OK |
| `Test rocm[libraries,devel]` | `Ran 27 tests` — OK |
| `Test rocm[profiler]` | `Ran 21 tests` — OK |

(Validated with workflow run since
[#8978](#8978) removes the ASAN GPU
runner fields unless the event is a pull_request in ROCm/rocm-systems.
An empty runner list skips Test Python rather than failing.)

Leak detection stays on rather than being switched off: LeakSanitizer
prints its suppression accounting at each exit and finds nothing outside
the suppressed templates.

```
Suppressions used:
  count      bytes template
      74      83083 libpython
```

**Counterfactual:** [run
40888153220](https://github.com/ROCm/TheRock/actions/runs/40888153220)
is the same wheels with `artifact_group` left empty, so the preload is
off. All three steps abort with `ASan runtime does not come first in
initial library list` and execute zero tests. With the input empty every
gate in this PR is off, which is `main`'s behaviour today — so that run
is #6331 reproduced against current wheels.

**Unit:** `build_tools/github_actions/tests/` — 17 new tests, all
passing, and no pre-existing test changed state.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:host-asan Opt-in to running multi-arch host-asan CI on a pull request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants