Skip to content

Commit 7416aa0

Browse files
Merge pull request #995 from ldorau/Add_assert0_in_umf_ba_destroy
Assert in umf_ba_destroy() in DEBUG and UMF_DEVELOPER_MODE
2 parents 522d35a + c549441 commit 7416aa0

7 files changed

+22
-8
lines changed

.github/workflows/reusable_proxy_lib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
-DUMF_BUILD_BENCHMARKS=OFF
5050
-DUMF_BUILD_TESTS=ON
5151
-DUMF_FORMAT_CODE_STYLE=OFF
52-
-DUMF_DEVELOPER_MODE=OFF
52+
-DUMF_DEVELOPER_MODE=ON
5353
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
5454
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
5555
-DUMF_TESTS_FAIL_ON_SKIP=ON

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ else()
111111
message(FATAL_ERROR "Unknown OS type")
112112
endif()
113113

114+
if(UMF_DEVELOPER_MODE)
115+
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
116+
UMF_DEVELOPER_MODE=1)
117+
endif()
118+
114119
if(NOT UMF_BUILD_LIBUMF_POOL_JEMALLOC)
115120
set(UMF_POOL_JEMALLOC_ENABLED FALSE)
116121
set(JEMALLOC_FOUND FALSE)

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ set(UMF_CUDA_INCLUDE_DIR
1414
# Compile definitions for UMF library.
1515
#
1616
# TODO: Cleanup the compile definitions across all the CMake files
17-
set(UMF_COMMON_COMPILE_DEFINITIONS UMF_VERSION=${UMF_VERSION})
17+
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
18+
UMF_VERSION=${UMF_VERSION})
1819

1920
set(BA_SOURCES
2021
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc.c

src/base_alloc/base_alloc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,13 @@ void umf_ba_destroy(umf_ba_pool_t *pool) {
303303
#ifndef NDEBUG
304304
ba_debug_checks(pool);
305305
if (pool->metadata.n_allocs) {
306-
LOG_ERR("pool->metadata.n_allocs = %zu", pool->metadata.n_allocs);
306+
LOG_ERR("number of base allocator memory leaks: %zu",
307+
pool->metadata.n_allocs);
308+
309+
#ifdef UMF_DEVELOPER_MODE
310+
assert(pool->metadata.n_allocs == 0 &&
311+
"memory leaks in base allocator occurred");
312+
#endif
307313
}
308314
#endif /* NDEBUG */
309315

test/provider_devdax_memory.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ TEST_F(test, test_if_mapped_with_MAP_SYNC) {
165165
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
166166

167167
umfMemoryProviderDestroy(hProvider);
168+
umfDevDaxMemoryProviderParamsDestroy(params);
168169

169170
// fail test if the "sf" flag was not found
170171
ASSERT_EQ(flag_found, true);

test/provider_file_memory.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ TEST_F(test, test_if_mapped_with_MAP_SYNC) {
162162
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
163163

164164
umfMemoryProviderDestroy(hProvider);
165+
umfFileMemoryProviderParamsDestroy(params);
165166

166167
// fail test if the "sf" flag was not found
167168
ASSERT_EQ(flag_found, true);

test/provider_os_memory_multiple_numa_nodes.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,17 +674,17 @@ TEST_P(testNumaSplit, checkModeSplit) {
674674
auto [required_numa_nodes, pages, in, out] = param;
675675
umf_result_t umf_result;
676676

677-
umf_os_memory_provider_params_handle_t os_memory_provider_params = nullptr;
678-
679-
umf_result = umfOsMemoryProviderParamsCreate(&os_memory_provider_params);
680-
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
681-
682677
std::vector<unsigned> numa_nodes = get_available_numa_nodes();
683678

684679
if (numa_nodes.size() < required_numa_nodes) {
685680
GTEST_SKIP_("Not enough numa nodes");
686681
}
687682

683+
umf_os_memory_provider_params_handle_t os_memory_provider_params = nullptr;
684+
685+
umf_result = umfOsMemoryProviderParamsCreate(&os_memory_provider_params);
686+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
687+
688688
ASSERT_EQ(out.size(), pages)
689689
<< "Wrong test input - out array size doesn't match page count";
690690

0 commit comments

Comments
 (0)