Skip to content

Commit d4aa3f4

Browse files
authored
Merge pull request #1341 from ldorau/Fix_debug_check_in_the_tracking_provider
Fix debug check in the tracking provider
2 parents a26b734 + fc744b7 commit d4aa3f4

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

.github/workflows/reusable_valgrind.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
-B ${{github.workspace}}/build
2929
-DCMAKE_BUILD_TYPE=Debug
3030
-DUMF_FORMAT_CODE_STYLE=OFF
31-
-DUMF_DEVELOPER_MODE=ON
31+
-DUMF_DEVELOPER_MODE=OFF
3232
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
3333
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
3434
-DUMF_BUILD_CUDA_PROVIDER=OFF

src/provider/provider_tracking.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ typedef struct tracker_alloc_info_t {
5050
// in the next level of map
5151
// falling within the current range
5252
size_t n_children;
53-
#ifndef NDEBUG
54-
size_t is_freed;
55-
#endif /* NDEBUG */
53+
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
54+
uint64_t is_freed;
55+
#endif
5656
} tracker_alloc_info_t;
5757

5858
typedef struct tracker_ipc_info_t {
@@ -194,9 +194,9 @@ umfMemoryTrackerAddAtLevel(umf_memory_tracker_handle_t hTracker, int level,
194194
value->pool = pool;
195195
value->size = size;
196196
value->n_children = 0;
197-
#ifndef NDEBUG
197+
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
198198
value->is_freed = 0;
199-
#endif /* NDEBUG */
199+
#endif
200200

201201
assert(level < MAX_LEVELS_OF_ALLOC_SEGMENT_MAP);
202202
int ret = critnib_insert(hTracker->alloc_segments_map[level],
@@ -276,10 +276,12 @@ static umf_result_t umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker,
276276
continue;
277277
}
278278

279-
#ifndef NDEBUG
279+
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
280280
// make sure rvalue is not freed
281-
assert(rvalue->is_freed != 0xDEADBEEF);
282-
#endif /* NDEBUG */
281+
uint64_t is_freed;
282+
utils_atomic_load_acquire_u64(&rvalue->is_freed, &is_freed);
283+
assert(is_freed != 0xDEADBEEF);
284+
#endif
283285

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

@@ -1354,10 +1356,10 @@ void umfTrackingMemoryProviderGetUpstreamProvider(
13541356

13551357
static void free_leaf(void *leaf_allocator, void *ptr) {
13561358
if (ptr) {
1357-
#ifndef NDEBUG
1359+
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
13581360
tracker_alloc_info_t *value = (tracker_alloc_info_t *)ptr;
1359-
value->is_freed = 0xDEADBEEF;
1360-
#endif /* NDEBUG */
1361+
utils_atomic_store_release_u64(&value->is_freed, 0xDEADBEEF);
1362+
#endif
13611363
umf_ba_free(leaf_allocator, ptr);
13621364
}
13631365
}

0 commit comments

Comments
 (0)