[llvm-bugs] [Bug 25735] New: llvm::cl::ParseCommandLineOptions casue double free or corruption when in multithread

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 3 23:53:35 PST 2015


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

            Bug ID: 25735
           Summary: llvm::cl::ParseCommandLineOptions casue double free or
                    corruption when in multithread
           Product: libraries
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: xiulipan at outlook.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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 at 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.

-- 
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/20151204/316a7b37/attachment.html>


More information about the llvm-bugs mailing list