TSan reports a race on vtable access (Clang/7)

I've hit a funky TSan warning: "data race on vptr (ctor/dtor vs virtual call) in StartImpl()". I fail to see a race as the object is constructed in the main thread and then a worker thread is started:

struct Client : public ClientInterface {
Client() {
auto op = new Op{this};
thread_ = std::thread([op] { op->StartImpl(); });

void Op::StartImpl() {
std::cout << "This is a race: " << owner_->VirtualFunction() << "\n";

struct TestClient : public Client {};

int main(int argc, char **argv) {
return 0;

The full report with a minimal/complete repro is here: https://github.com/google/sanitizers/issues/1063

What am I missing? Does TSan miss the fact that all data stores happen before the worker thread is started? Or is this about the vtable pointer which is adjusted during the object's construction in the main thread?


I think this case is described in https://github.com/google/sanitizers/wiki/ThreadSanitizerPopularDataRaces#data-race-on-vptr

Yes, that’s similar. I have just looked at the code gen and the vtable re-assignment races. Thanks a lot!