Skip to content

rocrtst: ASAN Fixes: Use hsa_amd_memory_pool_free under ASAN in TestAllocate#4033

Open
shwetagkhatri wants to merge 1 commit intodevelopfrom
users/shwetak/TestAllocate_hsa_amd_memory_pool_free
Open

rocrtst: ASAN Fixes: Use hsa_amd_memory_pool_free under ASAN in TestAllocate#4033
shwetagkhatri wants to merge 1 commit intodevelopfrom
users/shwetak/TestAllocate_hsa_amd_memory_pool_free

Conversation

@shwetagkhatri
Copy link
Contributor

Under ASAN, hsa_amd_memory_pool_allocate returns (base + PAGE_SIZE) due to the ASAN header offset. The hsa_memory_free function is not intercepted by the ASAN runtime, so it receives the offset pointer and fails to find it in the runtime's allocation_map_.

Use hsa_amd_memory_pool_free instead, which IS intercepted by ASAN and correctly strips the PAGE_SIZE offset before calling into ROCr.

This is consistent with the existing ASAN handling in MemAvailableTest

ASAN Error Fixed:
Warning: (false && "Can't find address in allocation map") in
hsa_status_t rocr::core::Runtime::FreeMemory(void *),
runtime.cpp:350
(repeated hundreds of times during Memory_Max_Mem test)

Test: rocrtstFunc.Memory_Max_Mem and rocrtstFunc.Memory_Available
now pass without warnings under ASAN

Motivation

Technical Details

JIRA ID

Test Plan

Test Result

Submission Checklist

…llocate

Under ASAN, hsa_amd_memory_pool_allocate returns (base + PAGE_SIZE)
due to the ASAN header offset. The hsa_memory_free function is not
intercepted by the ASAN runtime, so it receives the offset pointer
and fails to find it in the runtime's allocation_map_.

Use hsa_amd_memory_pool_free instead, which IS intercepted by ASAN
and correctly strips the PAGE_SIZE offset before calling into ROCr.

This is consistent with the existing ASAN handling in MemAvailableTest

ASAN Error Fixed:
  Warning: (false && "Can't find address in allocation map") in
  hsa_status_t rocr::core::Runtime::FreeMemory(void *),
  runtime.cpp:350
  (repeated hundreds of times during Memory_Max_Mem test)

Test: rocrtstFunc.Memory_Max_Mem and rocrtstFunc.Memory_Available
      now pass without warnings under ASAN
@shwetagkhatri shwetagkhatri requested a review from cfreeamd as a code owner March 13, 2026 01:09
Copilot AI review requested due to automatic review settings March 13, 2026 01:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates ROCr conformance test memory allocation/free logic to behave correctly under AddressSanitizer (ASAN), aligning Memory_Max_Mem behavior with existing ASAN handling already present in MemAvailableTest.

Changes:

  • Under ROCRTST_ASAN, replace hsa_memory_free with hsa_amd_memory_pool_free in MemoryTest::TestAllocate to avoid freeing an ASAN-offset pointer.
  • Add ASAN-specific rationale comments explaining the allocator/header offset behavior and why the AMD free API is required.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants