<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - llvm::cl::ParseCommandLineOptions casue double free or corruption when in multithread"
   href="https://llvm.org/bugs/show_bug.cgi?id=25735">25735</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm::cl::ParseCommandLineOptions casue double free or corruption when in multithread
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Support Libraries
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>xiulipan@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We are using clang as a frontend, and we tried to use it in multithread, but
the llvm::cl::ParseCommandLineOptions will cause  
double free or corruption (fasttop): 0x00007f36e40041d0 ***

dump core backtrace shows that:
(gdb) bt
#0  0x00007f478493bf79 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007f478493f388 in __GI_abort () at abort.c:89
#2  0x00007f4784f416b5 in __gnu_cxx::__verbose_terminate_handler() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007f4784f3f836 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007f4784f3f863 in std::terminate() () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007f4784f4033f in __cxa_pure_virtual () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007f4780ca6885 in llvm::cl::Option::addOccurrence (this=0x7f47829a0c20
<InlineLimit>, pos=1,
    ArgName=..., Value=..., MultiArg=false) at
/home/pxl/llvm/lib/Support/CommandLine.cpp:1140
#7  0x00007f4780ca1942 in CommaSeparateAndAddOccurrence (Handler=0x7f47829a0c20
<InlineLimit>, pos=1,
    ArgName=..., Value=..., MultiArg=false) at
/home/pxl/llvm/lib/Support/CommandLine.cpp:348
#8  0x00007f4780ca1c1e in ProvideOption (Handler=0x7f47829a0c20 <InlineLimit>,
ArgName=..., Value=...,
    argc=2, argv=0x7f477af6c3b8, i=@0x7f477af6bc98: 1) at
/home/pxl/llvm/lib/Support/CommandLine.cpp:389
#9  0x00007f4780ca4f25 in (anonymous
namespace)::CommandLineParser::ParseCommandLineOptions (
    this=0x19d0160, argc=2, argv=0x7f477af6c3b8, Overview=0x0)
    at /home/pxl/llvm/lib/Support/CommandLine.cpp:990
#10 0x00007f4780ca3c18 in llvm::cl::ParseCommandLineOptions (argc=2,
argv=0x7f475c004680, Overview=0x0)
    at /home/pxl/llvm/lib/Support/CommandLine.cpp:813

This bug does not happen in LLVM3.6, it seems the ParseCommandLineOptions was
refined and it is wrapped by a static manager:
[CommandLine.cpp]

00213 static ManagedStatic<CommandLineParser> GlobalParser;

00811 void cl::ParseCommandLineOptions(int argc, const char *const *argv,
00812                                  const char *Overview) {
00813   GlobalParser->ParseCommandLineOptions(argc, argv, Overview);
00814 }

And this static manager make each thread using the same CommandLineParser
object and cause this error.
May be the GlobalParser should be a TLS to make sure it is a thread safe as
other llvm component.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>