Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reusable_valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
-B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=Debug
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_DEVELOPER_MODE=OFF
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
-DUMF_BUILD_CUDA_PROVIDER=OFF
Expand Down
24 changes: 13 additions & 11 deletions src/provider/provider_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ typedef struct tracker_alloc_info_t {
// in the next level of map
// falling within the current range
size_t n_children;
#ifndef NDEBUG
size_t is_freed;
#endif /* NDEBUG */
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
uint64_t is_freed;
#endif
} tracker_alloc_info_t;

typedef struct tracker_ipc_info_t {
Expand Down Expand Up @@ -194,9 +194,9 @@ umfMemoryTrackerAddAtLevel(umf_memory_tracker_handle_t hTracker, int level,
value->pool = pool;
value->size = size;
value->n_children = 0;
#ifndef NDEBUG
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
value->is_freed = 0;
#endif /* NDEBUG */
#endif

assert(level < MAX_LEVELS_OF_ALLOC_SEGMENT_MAP);
int ret = critnib_insert(hTracker->alloc_segments_map[level],
Expand Down Expand Up @@ -276,10 +276,12 @@ static umf_result_t umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker,
continue;
}

#ifndef NDEBUG
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
// make sure rvalue is not freed
assert(rvalue->is_freed != 0xDEADBEEF);
#endif /* NDEBUG */
uint64_t is_freed;
utils_atomic_load_acquire_u64(&rvalue->is_freed, &is_freed);
assert(is_freed != 0xDEADBEEF);
#endif

utils_atomic_load_acquire_u64((uint64_t *)&rvalue->size, &rsize);

Expand Down Expand Up @@ -1354,10 +1356,10 @@ void umfTrackingMemoryProviderGetUpstreamProvider(

static void free_leaf(void *leaf_allocator, void *ptr) {
if (ptr) {
#ifndef NDEBUG
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
tracker_alloc_info_t *value = (tracker_alloc_info_t *)ptr;
value->is_freed = 0xDEADBEEF;
#endif /* NDEBUG */
utils_atomic_store_release_u64(&value->is_freed, 0xDEADBEEF);
#endif
umf_ba_free(leaf_allocator, ptr);
}
}
Expand Down
Loading