rocrtst: ASAN Fixes: Use hsa_amd_memory_pool_free under ASAN in TestAllocate#4033
Open
shwetagkhatri wants to merge 1 commit intodevelopfrom
Open
rocrtst: ASAN Fixes: Use hsa_amd_memory_pool_free under ASAN in TestAllocate#4033shwetagkhatri wants to merge 1 commit intodevelopfrom
shwetagkhatri wants to merge 1 commit intodevelopfrom
Conversation
…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
Contributor
There was a problem hiding this comment.
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, replacehsa_memory_freewithhsa_amd_memory_pool_freeinMemoryTest::TestAllocateto 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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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