It looks like ThreadSanitizer is giving you a false positive on the std::thread implementation.
Reducing your example to not do any set manipulations, like the following:
#include <iostream>
#include <thread>
#include <set>
int main()
{
std::set<int> bucket;
std::thread t([&](){ /*bucket.insert(5);*/ });
t.join();
return 0;
}
Still gives the same error in ThreadSanitizer.
Note that ThreadSanitizer does NOT find your read-write race condition.