[llvm-bugs] [Bug 38830] New: Memory corruption with CodeGenOnly in ThinLTOCodeGenerator

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 4 11:53:37 PDT 2018


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: unassignedbugs at nondot.org
          Reporter: alex.b.dv at gmail.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180904/eea3aec4/attachment.html>


More information about the llvm-bugs mailing list