Description
string generate(const string& prefix)
{
static map<string, int> prefixes;
stringstream out;
out << __sync_add_and_fetch(&prefixes[prefix], 1);
return prefix + "(" + out.str() + ")";
}
This function could be called from multiple threads and the std::map 'prefixes' is not protected by lock, leading to a race condition. This causes framework to segfault.