WARNING: ThreadSanitizer: data race (pid=586753)
Write of size 8 at 0x72500008fbc0 by main thread (mutexes: write M0):
#0 operator delete(void*, unsigned long) <null> (libtsan.so.2+0x69a1f) (BuildId: dc0ba0fbb4c898af5813c254dc49d26023dac0d0)
#1 std::__new_allocator<ALbufferQueueItem>::deallocate(ALbufferQueueItem*, unsigned long) /usr/include/c++/16/bits/new_allocator.h:183 (test.so+0xcc727f) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
#2 std::allocator_traits<std::allocator<ALbufferQueueItem> >::deallocate(std::allocator<ALbufferQueueItem>&, ALbufferQueueItem*, unsigned long) /usr/include/c++/16/bits/alloc_traits.h:689 (test.so+0xcc727f)
#3 std::_Deque_base<ALbufferQueueItem, std::allocator<ALbufferQueueItem> >::_M_deallocate_node(ALbufferQueueItem*) /usr/include/c++/16/bits/stl_deque.h:593 (test.so+0xcc727f)
#4 std::deque<ALbufferQueueItem, std::allocator<ALbufferQueueItem> >::_M_pop_front_aux() /usr/include/c++/16/bits/deque.tcc:581 (test.so+0xcc727f)
#5 std::deque<ALbufferQueueItem, std::allocator<ALbufferQueueItem> >::pop_front() /usr/include/c++/16/bits/stl_deque.h:1651 (test.so+0xcc727f)
#6 operator() openal-soft/al/source.cpp:3700 (test.so+0xcc727f)
#7 generate<al::ptr_wrapper<unsigned int*>, alSourceUnqueueBuffersDirect(ALCcontext*, ALuint, ALsizei, ALuint*)::<lambda()> > /usr/include/c++/16/bits/stl_algo.h:4375 (test.so+0xcc727f)
#8 alSourceUnqueueBuffersDirect openal-soft/al/source.cpp:3691 (test.so+0xcc727f)
#9 alSourceUnqueueBuffers openal-soft/al/source.cpp:3654 (test.so+0xcd6b13) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
Mutex M0 (0x726400177358) created at:
#0 pthread_mutex_lock <null> (libtsan.so.2+0x1f34a) (BuildId: dc0ba0fbb4c898af5813c254dc49d26023dac0d0)
#1 __gthread_mutex_lock(pthread_mutex_t*) /usr/include/c++/16/x86_64-redhat-linux/bits/gthr-default.h:795 (test.so+0xcc743a) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
#2 std::mutex::lock() /usr/include/c++/16/bits/std_mutex.h:116 (test.so+0xcc743a)
#3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/16/bits/std_mutex.h:276 (test.so+0xcc743a)
#4 UpdateAllSourceProps(ALCcontext*) openal-soft/al/source.cpp:3753 (test.so+0xcc743a)
#5 ALCcontext::applyAllUpdates() openal-soft/alc/context.cpp:328 (test.so+0xd07fab) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
#6 ALCcontext::processUpdates() openal-soft/alc/context.h:157 (test.so+0xcd8827) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
#7 alProcessUpdatesDirectSOFT openal-soft/al/state.cpp:570 (test.so+0xcd8827)
#8 alProcessUpdatesSOFT openal-soft/al/state.cpp:566 (test.so+0xcdb4fe) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
Mutex M1 (0x726800115110) created at:
#0 pthread_mutex_init <null> (libtsan.so.2+0x1ecf8) (BuildId: dc0ba0fbb4c898af5813c254dc49d26023dac0d0)
#1 <null> <null> (libspa-support.so+0x7878) (BuildId: eb1ea4612b561359f6f55592e107eff45b8454ad)
#2 alcOpenDevice openal-soft/alc/alc.cpp:3028 (test.so+0xceedfe) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
Thread T162 'ALSoftP0' (tid=587016, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.2+0x1fd4f) (BuildId: dc0ba0fbb4c898af5813c254dc49d26023dac0d0)
#1 <null> <null> (libpipewire-0.3.so.0+0x880ae) (BuildId: 3ab1d87839b33b9efa5f5c5ee1f43f8a296fd9e1)
#2 alcOpenDevice openal-soft/alc/alc.cpp:3028 (test.so+0xceedfe) (BuildId: 78c559b52be8b64dc4386d9bb04dce8a1a72b898)
SUMMARY: ThreadSanitizer: data race openal-soft/al/source.cpp:3700 in operator()****
Tsan reports
this is fixed by using the same refcount logic as
GetSourceSampleOffset. Not sure if this is just a false positive that should be silenced in another way though.