Issue occurs when doing ThinLTO with CodeGenOnly flag.
TMBuilder.TheTriple is assigned to by multiple threads in an unsafe way resulting in double-free of std::string memory.
Pseudocode:
if (CodeGenOnly) {
// Perform only parallel codegen and return. ThreadPool Pool; int count = 0; for (auto &ModuleBuffer : Modules) { Pool.async([&](int count) { ... /// Now call OutputBuffer = codegen(*TheModule); /// Which turns into initTMBuilder(moduleTMBuilder, Triple(TheModule.getTargetTriple())); /// Which turns into TMBuilder.TheTriple = std::move(TheTriple); // std::string = "....." /// So, basically std::string assignment to same string on multiple threads = memory corruption } return;
}