Skip to content

Commit 7051bb2

Browse files
committed
Add tests for tracking provider
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 716b562 commit 7051bb2

File tree

3 files changed

+387
-2
lines changed

3 files changed

+387
-2
lines changed

src/coarse/coarse.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,13 @@ umf_result_t coarse_free(coarse_t *coarse, void *ptr, size_t bytes) {
11701170
}
11711171

11721172
block_t *block = get_node_block(node);
1173-
assert(block->used);
1173+
if (!block->used) {
1174+
LOG_ERR("double free");
1175+
utils_mutex_unlock(&coarse->lock);
1176+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
1177+
}
11741178

11751179
if (bytes > 0 && bytes != block->size) {
1176-
// wrong size of allocation
11771180
LOG_ERR("wrong size of allocation");
11781181
utils_mutex_unlock(&coarse->lock);
11791182
return UMF_RESULT_ERROR_INVALID_ARGUMENT;

test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented
343343
NAME provider_fixed_memory
344344
SRCS provider_fixed_memory.cpp
345345
LIBS ${UMF_UTILS_FOR_TEST})
346+
add_umf_test(
347+
NAME provider_tracking
348+
SRCS provider_tracking.cpp
349+
LIBS ${UMF_UTILS_FOR_TEST})
346350

347351
# This test requires Linux-only file memory provider
348352
if(UMF_POOL_JEMALLOC_ENABLED)

0 commit comments

Comments
 (0)