https://bugs.llvm.org/show_bug.cgi?id=38830

            Bug ID: 38830
           Summary: Memory corruption with CodeGenOnly in
                    ThinLTOCodeGenerator
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedb...@nondot.org
          Reporter: alex.b...@gmail.com
                CC: llvm-bugs@lists.llvm.org

When running with ThinLTO & CodeGenOnly, TMBuilder.TheTriple is initialized
from multiple threads in a non-thread-safe way.

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;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to