From db59630f8f195dfe684a5f1762f7a07897db966c Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Mon, 14 Apr 2025 12:34:32 +0200 Subject: [PATCH] Use atomics in trackingAlloc() Use utils_atomic_store_release_ptr() atomics in trackingAlloc(). It fixes a data race detected by TSAN. Signed-off-by: Lukasz Dorau --- src/provider/provider_tracking.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/provider/provider_tracking.c b/src/provider/provider_tracking.c index bf316aa629..e9c911c261 100644 --- a/src/provider/provider_tracking.c +++ b/src/provider/provider_tracking.c @@ -471,7 +471,7 @@ static umf_result_t trackingAlloc(void *hProvider, size_t size, assert(p->hUpstream); - *_ptr = NULL; + utils_atomic_store_release_ptr(_ptr, NULL); ret = umfMemoryProviderAlloc(p->hUpstream, size, alignment, &ptr); if (ret != UMF_RESULT_SUCCESS || !ptr) { @@ -492,7 +492,7 @@ static umf_result_t trackingAlloc(void *hProvider, size_t size, return ret; } - *_ptr = ptr; + utils_atomic_store_release_ptr(_ptr, ptr); return UMF_RESULT_SUCCESS; }