Skip to content

Commit c549441

Browse files
committed
Assert in umf_ba_destroy() in DEBUG and UMF_DEVELOPER_MODE
if (NDEBUG is not defined) and (UMF_DEVELOPER_MODE is defined) assert in umf_ba_destroy() if there are any memory leaks in the base allocator. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent a714e45 commit c549441

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
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

0 commit comments

Comments
 (0)