Skip to content

Race in jemalloc pool multithreaded test #1244

@PatKamin

Description

@PatKamin

Critnib data race in the jemallocPoolTest/umfPoolTest.multiThreadedMallocFree/0 test

Environment Information

  • OS(es) version(s): Ubuntu 22.04
  • kernel version(s): 6.8
  • compiler, libraries, and other related tools version(s): clang 14.0

Please provide a reproduction of the bug:

CI job that reproduces: https://github.com/oneapi-src/unified-memory-framework/actions/runs/14328799263/job/40160676904?pr=1243

cmake
-B build
-DCMAKE_BUILD_TYPE=Debug
-DUMF_BUILD_SHARED_LIBRARY=OFF
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_BUILD_CUDA_PROVIDER=ON
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_USE_ASAN=OFF
-DUMF_USE_UBSAN=OFF
-DUMF_USE_TSAN=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON
cmake --build build

How often bug is revealed:

from time to time

Actual behavior:

Run: ctest --output-on-failure

UMMARY: ThreadSanitizer: data race /home/runner/work/unified-memory-framework/unified-memory-framework/src/critnib/critnib.c:763:26 in critnib_find
==================
==================
WARNING: ThreadSanitizer: data race (pid=12264)
  Atomic read of size 8 at 0x7f889ca40e00 by thread T2 (mutexes: write M0):
    #0 utils_atomic_load_acquire_u64 /home/runner/work/unified-memory-framework/unified-memory-framework/src/utils/utils_concurrency.h:166:5 (test_jemalloc_pool+0x16722d) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #1 umfMemoryTrackerAdd /home/runner/work/unified-memory-framework/unified-memory-framework/src/provider/provider_tracking.c:202:9 (test_jemalloc_pool+0x166e9a) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #2 trackingAlloc /home/runner/work/unified-memory-framework/unified-memory-framework/src/provider/provider_tracking.c:481:11 (test_jemalloc_pool+0x1641e7) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #3 umfMemoryProviderAlloc /home/runner/work/unified-memory-framework/unified-memory-framework/src/memory_provider.c:245:9 (test_jemalloc_pool+0x1597be) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #4 arena_extent_alloc /home/runner/work/unified-memory-framework/unified-memory-framework/src/pool/pool_jemalloc.c:105:11 (test_jemalloc_pool+0x16c5c7) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #5 ehooks_alloc /home/runner/work/unified-memory-framework/unified-memory-framework/build/_deps/jemalloc_targ-src/include/jemalloc/internal/ehooks.h:201:9 (test_jemalloc_pool+0x28842c) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #6 extent_grow_retained /home/runner/work/unified-memory-framework/unified-memory-framework/build/_deps/jemalloc_targ-src/src/extent.c:672:14 (test_jemalloc_pool+0x28842c)
    #7 extent_alloc_retained /home/runner/work/unified-memory-framework/unified-memory-framework/build/_deps/jemalloc_targ-src/src/extent.c:791:11 (test_jemalloc_pool+0x28842c)
    #8 je_ecache_alloc_grow /home/runner/work/unified-memory-framework/unified-memory-framework/build/_deps/jemalloc_targ-src/src/extent.c:104:19 (test_jemalloc_pool+0x28842c)
    #9 umfPoolMalloc /home/runner/work/unified-memory-framework/unified-memory-framework/src/memory_pool.c:189:12 (test_jemalloc_pool+0x158841) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #10 umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0::operator()(unsigned long, umf_memory_pool_t*) const /home/runner/work/unified-memory-framework/unified-memory-framework/test/poolFixtures.hpp:223:38 (test_jemalloc_pool+0x10258f) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #11 void std::__invoke_impl<void, umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*>(std::__invoke_other, umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0&&, unsigned long&&, umf_memory_pool_t*&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:61:14 (test_jemalloc_pool+0x1024da) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #12 std::__invoke_result<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*>::type std::__invoke<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*>(umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0&&, unsigned long&&, umf_memory_pool_t*&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:96:14 (test_jemalloc_pool+0x102327) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #13 void std::thread::_Invoker<std::tuple<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*> >::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:279:13 (test_jemalloc_pool+0x10229b) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #14 std::thread::_Invoker<std::tuple<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*> >::operator()() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:286:11 (test_jemalloc_pool+0x102205) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #15 std::thread::_State_impl<std::thread::_Invoker<std::tuple<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*> > >::_M_run() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:231:13 (test_jemalloc_pool+0x102029) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #16 <null> <null> (libstdc++.so.6+0xdc252) (BuildId: e37fe1a879783838de78cbc8c80621fa685d58a2)

  Previous write of size 8 at 0x7f889ca40e00 by thread T3 (mutexes: write M1):
    #0 trackingAllocationSplit /home/runner/work/unified-memory-framework/unified-memory-framework/src/provider/provider_tracking.c:516:22 (test_jemalloc_pool+0x165[244](https://github.com/oneapi-src/unified-memory-framework/actions/runs/14328799263/job/40160676904?pr=1243#step:7:245)) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #1 umfMemoryProviderAllocationSplit /home/runner/work/unified-memory-framework/unified-memory-framework/src/memory_provider.c:332:24 (test_jemalloc_pool+0x15a17c) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #2 arena_extent_split /home/runner/work/unified-memory-framework/unified-memory-framework/src/pool/pool_jemalloc.c:274:12 (test_jemalloc_pool+0x16cb46) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #3 ehooks_split /home/runner/work/unified-memory-framework/unified-memory-framework/build/_deps/jemalloc_targ-src/include/jemalloc/internal/ehooks.h:342:14 (test_jemalloc_pool+0x28569f) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #4 extent_split_impl.constprop.0 /home/runner/work/unified-memory-framework/unified-memory-framework/build/_deps/jemalloc_targ-src/src/extent.c:1216:8 (test_jemalloc_pool+0x28569f)
    #5 umfPoolMalloc /home/runner/work/unified-memory-framework/unified-memory-framework/src/memory_pool.c:189:12 (test_jemalloc_pool+0x158841) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #6 umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0::operator()(unsigned long, umf_memory_pool_t*) const /home/runner/work/unified-memory-framework/unified-memory-framework/test/poolFixtures.hpp:223:38 (test_jemalloc_pool+0x10258f) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #7 void std::__invoke_impl<void, umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*>(std::__invoke_other, umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0&&, unsigned long&&, umf_memory_pool_t*&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:61:14 (test_jemalloc_pool+0x1024da) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #8 std::__invoke_result<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*>::type std::__invoke<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*>(umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0&&, unsigned long&&, umf_memory_pool_t*&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:96:14 (test_jemalloc_pool+0x102327) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #9 void std::thread::_Invoker<std::tuple<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*> >::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:279:13 (test_jemalloc_pool+0x10229b) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #10 std::thread::_Invoker<std::tuple<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*> >::operator()() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:286:11 (test_jemalloc_pool+0x102205) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<umfPoolTest_multiThreadedMallocFree_Test::TestBody()::$_0, unsigned long, umf_memory_pool_t*> > >::_M_run() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:231:13 (test_jemalloc_pool+0x102029) (BuildId: ea7acfeb9a74313d3c4491e6fc94f5b66b85d9b9)
    #12 <null> <null> (libstdc++.so.6+0xdc[252](https://github.com/oneapi-src/unified-memory-framework/actions/runs/14328799263/job/40160676904?pr=1243#step:7:253)) (BuildId: e37fe1a879783838de78cbc8c80621fa685d58a2)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions