<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - lld-link crash with SafeSEH and -debug:dwarf"
   href="https://bugs.llvm.org/show_bug.cgi?id=37584">37584</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lld-link crash with SafeSEH and -debug:dwarf
          </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>All
          </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>COFF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>smeenai@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>compnerd@compnerd.org, llvm-bugs@lists.llvm.org, peter@pcc.me.uk, rnk@google.com, ruiu@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>% cat reduced.s
.globl _main
_main:
        ret
.safeseh _main

% clang -target i686-windows-msvc -c reduced.s
% lld-link -entry:main -debug:dwarf reduced.o
(segmentation fault)

We're segfaulting when attempting to write the symbol table, at
<a href="https://reviews.llvm.org/diffusion/L/browse/lld/trunk/COFF/Writer.cpp;333237$650">https://reviews.llvm.org/diffusion/L/browse/lld/trunk/COFF/Writer.cpp;333237$650</a>.
The symbol is the .sxdata section symbol, which has an RVA of 0. Since the RVA
is 0, whereas the first OutputSection has RVA 4096, we'll break out of the loop
above without ever assigning to Sec, so that'll remain nullptr, hence the
segfault.

This was broken by <a href="https://reviews.llvm.org/D42592">https://reviews.llvm.org/D42592</a>. I think the reason that
diff broke it is that, prior to it, we would discard .sxdata sections from
input files early
(<a href="https://reviews.llvm.org/diffusion/L/browse/lld/trunk/COFF/InputFiles.cpp;324305$154-162">https://reviews.llvm.org/diffusion/L/browse/lld/trunk/COFF/InputFiles.cpp;324305$154-162</a>),
so we never had the chance to reach the problematic path in the writer.

I'm thinking the .sxdata section symbol having an RVA of 0 is incorrect.
Thoughts on why that might be happening?</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>