Index: lib/tsan/rtl/tsan_interceptors.cc =================================================================== --- lib/tsan/rtl/tsan_interceptors.cc +++ lib/tsan/rtl/tsan_interceptors.cc @@ -1354,10 +1354,16 @@ if (o == 0 || f == 0) return errno_EINVAL; atomic_uint32_t *a; - if (!SANITIZER_MAC) - a = static_cast(o); - else // On OS X, pthread_once_t has a header with a long-sized signature. - a = static_cast((void *)((char *)o + sizeof(long_t))); + +#if SANITIZER_MAC + a = static_cast((void *)((char *)o + sizeof(long_t))); +#elif SANITIZER_NETBSD + a = static_cast + ((void *)((char *)o + __sanitizer::pthread_t_sz)); +#else + a = static_cast(o); +#endif + u32 v = atomic_load(a, memory_order_acquire); if (v == 0 && atomic_compare_exchange_strong(a, &v, 1, memory_order_relaxed)) {