Fix move assignment, and add test that exposed the bug.
Also fix default constructing and destrucrting a std::thread, along with a test that exposed the bug (which was a random crash due to the std::function construct never being called).
Finally, atomic.hpp's history_ is updated to be zero-initialized after MSAN reported an uninitialized memory read.
==11872==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x55f772a853ed in unsigned int rl::thread_info<2>::get_load_index<(rl::memory_order)0, false>(rl::atomic_data_impl<2>&) /home/ccotter/git/relacy/test/../relacy/thread.hpp:220:21
#1 0x55f772a83d17 in unsigned int rl::thread_info<2>::atomic_load<(rl::memory_order)0, false>(rl::atomic_data*) /home/ccotter/git/relacy/test/../relacy/thread.hpp:273:26
#2 0x55f772a7a382 in rl::thread_info<2>::atomic_load_relaxed(rl::atomic_data*) /home/ccotter/git/relacy/test/../relacy/thread.hpp:134:16
#3 0x55f772b196df in int rl::generic_atomic<int, true>::load_impl<(rl::memory_order)0, &rl::thread_info_base::atomic_load_relaxed(rl::atomic_data*)>(rl::debug_info const&) const /home/ccotter/git/relacy/test/../relacy/atomic.hpp:449:36
#4 0x55f772b18d08 in rl::generic_atomic<int, true>::load(rl::memory_order, rl::debug_info const&) const /home/ccotter/git/relacy/test/../relacy/atomic.hpp:235:33
#5 0x55f772b0fc4f in test_FlushProcessWriteBuffers::thread(unsigned int) /home/ccotter/git/relacy/test/windows.hpp:329:21
#6 0x55f772a69344 in rl::context_impl<test_FlushProcessWriteBuffers, rl::random_scheduler<2>>::fiber_proc_impl(int) /home/ccotter/git/relacy/test/../relacy/context.hpp:482:37
#7 0x55f772a5f24f in rl::context_impl<test_FlushProcessWriteBuffers, rl::random_scheduler<2>>::fiber_proc(void*) /home/ccotter/git/relacy/test/../relacy/context.hpp:1046:11
#8 0x55f772953ce5 in fiber_start_fnc(void*) /home/ccotter/git/relacy/test/../relacy/platform.hpp:189:5
#9 0x7f4c1d77118f (/lib64/libc.so.6+0x4818f) (BuildId: 2df8053b3adc8934cfeb0f11c1322ec6948085d5)
Uninitialized value was created by a heap allocation
#0 0x55f77291c3dd in malloc /tmp/compiler-rt-17.0-17.0.6-2/lib/msan/msan_interceptors.cpp:955:3
SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/ccotter/git/relacy/test/../relacy/thread.hpp:220:21 in unsigned int rl::thread_info<2>::get_load_index<(rl::memory_order)0, false>(rl::atomic_data_impl<2>&)
Fix move assignment, and add test that exposed the bug.
Also fix default constructing and destrucrting a
std::thread
, along with a test that exposed the bug (which was a random crash due to thestd::function
construct never being called).Finally, atomic.hpp's
history_
is updated to be zero-initialized after MSAN reported an uninitialized memory read.