<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 --- - rL256003 breaks LTO with debug info"
   href="https://llvm.org/bugs/show_bug.cgi?id=25915">25915</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>rL256003 breaks LTO with debug info
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>krasin@google.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>Consider the following program:

$ cat lala.cc
const char lala[] = { 0 };

Let's compile it with -flto and -g, and link using Gold plugin:

$ /usr/local/google/home/krasin/src/llvm.org/release-build/bin/clang++ -flto -g
-fuse-ld=gold -o lala lala.cc
clang-3.8: error: unable to execute command: Segmentation fault (core dumped)
clang-3.8: error: linker command failed due to signal (use -v to see
invocation)

Gold under gdb:

Program received signal SIGSEGV, Segmentation fault.
(anonymous namespace)::IRLinker::findNeededSubprograms
(this=this@entry=0x7fffffff6350, ValueMap=...) at
/usr/local/google/home/krasin/src/llvm.org/llvm/lib/Linker/IRMover.cpp:1196
1196        for (const Metadata *Op : CU->getSubprograms()->operands()) {
(gdb) bt
#0  (anonymous namespace)::IRLinker::findNeededSubprograms
(this=this@entry=0x7fffffff6350, ValueMap=...) at
/usr/local/google/home/krasin/src/llvm.org/llvm/lib/Linker/IRMover.cpp:1196
#1  0x00007ffff454e361 in linkNamedMDNodes (this=0x7fffffff6350) at
/usr/local/google/home/krasin/src/llvm.org/llvm/lib/Linker/IRMover.cpp:1250
#2  run (this=0x7fffffff6350) at
/usr/local/google/home/krasin/src/llvm.org/llvm/lib/Linker/IRMover.cpp:1520
#3  llvm::IRMover::move(llvm::Module&, llvm::ArrayRef<llvm::GlobalValue*>,
std::function<void (llvm::GlobalValue&, std::function<void
(llvm::GlobalValue&)>)>, llvm::DenseMap<unsigned int, llvm::MDNode*,
llvm::DenseMapInfo<unsigned int>, llvm::detail::DenseMapPair<unsigned int,
llvm::MDNode*> >*, bool) (this=this@entry=0x7fffffff6a30, Src=...,
ValuesToLink=..., AddLazyFor=..., ValIDToTempMDMap=ValIDToTempMDMap@entry=0x0,
IsMetadataLinkingPostpass=IsMetadataLinkingPostpass@entry=false) at
/usr/local/google/home/krasin/src/llvm.org/llvm/lib/Linker/IRMover.cpp:1654
#4  0x00007ffff3be433d in allSymbolsReadHook (ApiFile=ApiFile@entry=0x0) at
/usr/local/google/home/krasin/src/llvm.org/llvm/tools/gold/gold-plugin.cpp:910
#5  0x00007ffff3be66ab in all_symbols_read_hook () at
/usr/local/google/home/krasin/src/llvm.org/llvm/tools/gold/gold-plugin.cpp:955
#6  0x00000000004d5aef in ?? ()
#7  0x00000000004d5c24 in ?? ()
#8  0x0000000000516c65 in ?? ()
#9  0x0000000000516fca in ?? ()
#10 0x0000000000404f32 in ?? ()
#11 0x00007ffff7313ec5 in __libc_start_main (main=0x404a80, argc=37,
argv=0x7fffffffd708, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffd6f8) at libc-start.c:287
#12 0x0000000000405e41 in ?? ()


This is introduced in <a href="http://reviews.llvm.org/rL256003">http://reviews.llvm.org/rL256003</a> and the immediate
problem is in the line IRMover.cpp:1197 that makes an assumption that
CU->getSubprograms() will always return a non-NULL value.

This was initially discovered on one of Chromium buildbots, see
<a href="https://crbug.com/570694#c14">https://crbug.com/570694#c14</a></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>