Skip to content

Fix asan leak in hip-samples - #12907

Merged
vstojilj merged 1 commit into
developfrom
users/vstojilj/sample_module_asan_leak
Oct 12, 2026
Merged

vstojilj merged 1 commit into
developfrom
users/vstojilj/sample_module_asan_leak

Conversation

@vstojilj

@vstojilj vstojilj commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

Fix an AddressSanitizer leak reported when the module_api_global HIP sample exits after loading a code object.

Technical Details

The sample loaded the module with hipModuleLoad but never released it. Added hipModuleUnload(Module) after the final module use. This destroys the underlying executable and releases the duplicated code-object URI.

Issue Tracking

JIRA ID: ROCM-32204

Test Plan

Build module_api_global against an ASAN-enabled ROCm build and run it with:
ASAN_OPTIONS="detect_leaks=1:symbolize=1".

Test Result

The rebuilt sample exited with code 0, both validation checks printed PASSED!, and LeakSanitizer reported no leaks

Submission Checklist

Copilot AI balanced review requested due to automatic review settings October 6, 2026 13:23
@vstojilj
vstojilj requested a review from a team as a code owner October 6, 2026 13:23
@therock-pr-bot

therock-pr-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/hip-tests/samples/0_Intro/module_api_global/runKernel.cpp; no test file found
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

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

🙋 Wish to Override Policy?

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The module is correctly unloaded after all uses and before context destruction.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes the HIP sample’s module resource leak by releasing the loaded code object before destroying its context.

Changes:

  • Unloads the HIP module after its final use.
File Description
projects/​hip-tests/​samples/​0_Intro/​module_api_global/​runKernel.cpp Releases the loaded module during cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vstojilj
vstojilj merged commit 0e449ad into develop Oct 12, 2026
256 of 283 checks passed
@vstojilj
vstojilj deleted the users/vstojilj/sample_module_asan_leak branch October 12, 2026 10:31
systems-assistant Bot pushed a commit to ROCm/hip-tests that referenced this pull request Oct 12, 2026
## Motivation

<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->
Fix an AddressSanitizer leak reported when the module_api_global HIP
sample exits after loading a code object.

## Technical Details

<!-- Explain the changes along with any relevant GitHub links. -->
The sample loaded the module with hipModuleLoad but never released it.
Added hipModuleUnload(Module) after the final module use. This destroys
the underlying executable and releases the duplicated code-object URI.

## Issue Tracking

<!-- Include a GitHub Issue and/or JIRA ID. Do not post any full JIRA
links here. -->
<!-- GitHub issue: ROCm/rocm-systems#1234 -->
<!-- JIRA ID: EXAMPLECOMPONENT-1234 -->
JIRA ID: ROCM-32204

## Test Plan

<!-- Explain any relevant testing done to verify this PR. -->
Build module_api_global against an ASAN-enabled ROCm build and run it
with:
ASAN_OPTIONS="detect_leaks=1:symbolize=1".

## Test Result

<!-- Briefly summarize test outcomes. -->
The rebuilt sample exited with code 0, both validation checks printed
PASSED!, and LeakSanitizer reported no leaks

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.
[rocm-systems] ROCm/rocm-systems#12907 (commit 0e449ad)
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants