The critical section in __tsan_thread_start_func() where the associated ThreadState object is not completely initialized contains a pthread_setspecific() call which in turn use calloc() on FreeBSD. The calloc() call thus relies on under-initialized thread state data and leads to generating the "data race" kind of error.
extern "C" void *__tsan_thread_start_func(void *arg) {
...
{
ThreadState *thr = cur_thread();
// Thread-local state is not initialized yet.
ScopedIgnoreInterceptors ignore;
if (pthread_setspecific(g_thread_finalize_key,
(void *)kPthreadDestructorIterations)) {
Printf("ThreadSanitizer: failed to set thread key\n");
Die();
}
...
}
...
}