Skip to content

Commit

Permalink
Merge pull request #263 from coldav/colin/fix_asan_issues
Browse files Browse the repository at this point in the history
Fix asan memory leaks
  • Loading branch information
coldav authored Dec 18, 2023
2 parents 94d02d4 + 5bf5ba7 commit 58eeee1
Showing 1 changed file with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ TEST_F(USMTests, SingleSharedMemAlloc_ValidUsage) {
EXPECT_TRUE(shared_ptr != nullptr);
}

if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}
shared_ptr = clSharedMemAllocINTEL(context, device, nullptr, bytes, 0, &err);
if (!shared_mem_support) {
EXPECT_EQ_ERRCODE(err, CL_INVALID_OPERATION);
Expand All @@ -455,6 +459,11 @@ TEST_F(USMTests, SingleSharedMemAlloc_ValidUsage) {
EXPECT_TRUE(shared_ptr != nullptr);
}

if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}

const cl_mem_properties_intel no_properties[] = {0};
shared_ptr =
clSharedMemAllocINTEL(context, device, no_properties, bytes, align, &err);
Expand All @@ -465,7 +474,10 @@ TEST_F(USMTests, SingleSharedMemAlloc_ValidUsage) {
EXPECT_SUCCESS(err);
EXPECT_TRUE(shared_ptr != nullptr);
}

if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}
const cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, 0, 0};
shared_ptr =
clSharedMemAllocINTEL(context, device, properties, bytes, align, &err);
Expand All @@ -476,6 +488,10 @@ TEST_F(USMTests, SingleSharedMemAlloc_ValidUsage) {
EXPECT_SUCCESS(err);
EXPECT_TRUE(shared_ptr != nullptr);
}
if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}
}

// Test for invalid API usage of clSharedMemAllocINTEL without an associated
Expand Down Expand Up @@ -590,6 +606,10 @@ TEST_F(USMTests, CrossSharedMemAlloc_ValidUsage) {
EXPECT_SUCCESS(err);
EXPECT_TRUE(shared_ptr != nullptr);
}
if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}

shared_ptr = clSharedMemAllocINTEL(context, nullptr, nullptr, bytes, 0, &err);
if (!shared_mem_support) {
Expand All @@ -599,6 +619,10 @@ TEST_F(USMTests, CrossSharedMemAlloc_ValidUsage) {
EXPECT_SUCCESS(err);
EXPECT_TRUE(shared_ptr != nullptr);
}
if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}

const cl_mem_properties_intel no_properties[] = {0};
shared_ptr = clSharedMemAllocINTEL(context, nullptr, no_properties, bytes,
Expand All @@ -610,6 +634,10 @@ TEST_F(USMTests, CrossSharedMemAlloc_ValidUsage) {
EXPECT_SUCCESS(err);
EXPECT_TRUE(shared_ptr != nullptr);
}
if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}

const cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, 0, 0};
shared_ptr =
Expand All @@ -621,6 +649,10 @@ TEST_F(USMTests, CrossSharedMemAlloc_ValidUsage) {
EXPECT_SUCCESS(err);
EXPECT_TRUE(shared_ptr != nullptr);
}
if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}
}

using USMAllocFlagTest = USMWithParam<cl_mem_alloc_flags_intel>;
Expand Down Expand Up @@ -703,8 +735,10 @@ TEST_P(USMAllocFlagTest, SharedAlloc) {
EXPECT_SUCCESS(err);
EXPECT_TRUE(shared_ptr != nullptr);

err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
if (shared_ptr) {
err = clMemBlockingFreeINTEL(context, shared_ptr);
EXPECT_SUCCESS(err);
}
}

INSTANTIATE_TEST_SUITE_P(
Expand Down

0 comments on commit 58eeee1

Please sign in to comment.