From running with TSAN locally, I get a data race reported for access to halide_profiler_get_state():
WARNING: ThreadSanitizer: data race (pid=51457)
Read of size 4 at 0x7ff87234c548 by thread T5:
#0 Halide::Runtime::Internal::sampling_profiler_thread(void*) <null> (libthird_Uparty_Shalide_Slibhalide_Ulibrary_Uruntime.so+0x19bc6)
#1 Halide::Runtime::Internal::spawn_thread_helper(void*) <null> (libthird_Uparty_Shalide_Slibhalide_Ulibrary_Uruntime.so+0xe1cd)
Previous write of size 4 at 0x7ff87234c548 by main thread:
#0 halide_profiler_pipeline_end <null> (libthird_Uparty_Shalide_Slibhalide_Ulibrary_Uruntime.so+0x1a2fa)
#1 <user-provided halide code>
Location is global 'halide_profiler_get_state::s' of size 48 at 0x7ff87234c538 (libthird_Uparty_Shalide_Slibhalide_Ulibrary_Uruntime.so+0x00000001d548)
Thread T5 (tid=51474, running) created by main thread at:
#0 pthread_create third_party/llvm/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:962:3 (halide_target_map_test+0xf828a)
#1 halide_spawn_thread <null> (libthird_Uparty_Shalide_Slibhalide_Ulibrary_Uruntime.so+0xe185)
#2 halide_profiler_pipeline_start <null> (libthird_Uparty_Shalide_Slibhalide_Ulibrary_Uruntime.so+0x19df0)
#3 <user-provided halide code>
From running with TSAN locally, I get a data race reported for access to
halide_profiler_get_state()
: