Skip to content

Commit cc024af

Browse files
umfranzwNguyenNhuDi
authored andcommitted
[rocm-libraries] ROCm/rocm-libraries#5879 (commit 26c1235)
[rocThrust] Disable tests under too large for ASAN in ASAN builds (#5879) ## Motivation VectorTests (vector.hip) TestVectorResizeing and TestVectorReserving attempt to allocate `std::numeric_limits<size_t>::max()` bytes on the host inside a try/catch block, and test what happens when it fails. In ASAN builds, this causes ASAN to fail because it cannot allocate a buffer that large. ## Technical Details This changes disables these test sizes when running an ASAN build. ## Test Plan Build rocThrust with `-DADDRESS_SANITIZER=ON` and run the `vector.hip` target. Verify that it does not crash with message `AddressSanitizer: requested allocation size ... exceeds maximum supported size.` ## Test Result Test does not crash with ASAN out of memory error. ## Submission Checklist - [ ] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests. Co-authored-by: Di Nguyen <dinguyennhu@gmail.com>
1 parent f02698e commit cc024af

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ endif()
207207

208208
# Address Sanitizer
209209
if(BUILD_ADDRESS_SANITIZER)
210+
add_compile_definitions(ADDRESS_SANITIZER_BUILD)
210211
list(APPEND COMPILE_OPTIONS -fsanitize=address -shared-libasan)
211212
add_link_options(-fuse-ld=lld)
212213
endif()

test/test_vector.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ TYPED_TEST(VectorTests, TestVectorResizing)
676676

677677
ASSERT_EQ(v.size(), 0lu);
678678

679+
#ifndef ADDRESS_SANITIZER_BUILD
679680
// depending on sizeof(T), we will receive one
680681
// of two possible exceptions
681682
try
@@ -691,6 +692,7 @@ TYPED_TEST(VectorTests, TestVectorResizing)
691692
} // end catch
692693

693694
ASSERT_EQ(v.size(), 0lu);
695+
#endif
694696
}
695697

696698
TYPED_TEST(VectorTests, TestVectorReserving)
@@ -711,6 +713,7 @@ TYPED_TEST(VectorTests, TestVectorReserving)
711713

712714
ASSERT_EQ(v.capacity(), old_capacity);
713715

716+
#ifndef ADDRESS_SANITIZER_BUILD
714717
try
715718
{
716719
v.reserve(std::numeric_limits<size_t>::max());
@@ -721,6 +724,7 @@ TYPED_TEST(VectorTests, TestVectorReserving)
721724
{}
722725

723726
ASSERT_EQ(v.capacity(), old_capacity);
727+
#endif
724728
}
725729

726730
TEST(VectorTests, TestVectorUninitialisedCopy)

0 commit comments

Comments
 (0)