<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 mingw64: invalid memory access leads to deadlock"
   href="https://bugs.llvm.org/show_bug.cgi?id=36785">36785</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lld mingw64: invalid memory access leads to deadlock
          </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>Windows NT
          </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>daniel.f.starke@freenet.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20086" name="attach_20086" title="drmemory extract">attachment 20086</a> <a href="attachment.cgi?id=20086&action=edit" title="drmemory extract">[details]</a></span>
drmemory extract

I build clang/llvm 6.0.0 including lld with GCC 7.3.0 for mingw-w64 using
<a href="https://sourceforge.net/projects/gcc-win64/files/7.3.0/">https://sourceforge.net/projects/gcc-win64/files/7.3.0/</a> and the following
configuration:
cmake -G 'Ninja' -DCMAKE_BUILD_TYPE=Debug -DDEFAULT_SYSROOT=/mingw64-64
-DGCC_INSTALL_PREFIX=/mingw64-64 -DCMAKE_INSTALL_PREFIX=/mingw64-64
'-DCMAKE_C_FLAGS=' '-DCMAKE_CXX_FLAGS=-std=c++14' '-DLLVM_TARGETS_TO_BUILD=X86'
-DLLVM_BUILD_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF -DCLANG_INCLUDE_DOCS=OFF
-DBUILD_SHARED_LIBS=OFF -DLLVM_POLLY_LINK_INTO_TOOLS=ON ../llvm-6.0.0.src
and this patch:
<a href="https://reviews.llvm.org/D43786">https://reviews.llvm.org/D43786</a>

I replaced my system ld.exe with lld.exe and executed the following
command-line:
ld.exe --sysroot=E:/msys/mingw64-64 -s -m i386pep -Bstatic -o bin/pp.exe -s
"E:/msys/mingw64-64\x86_64-w64-mingw32\lib\crt2u.o"
"E:/msys/mingw64-64\lib\gcc\x86_64-w64-mingw32\7.3.0\crtbegin.o" -Llib64
-L../libpcfxx/lib64 "-LE:/msys/mingw64-64\lib\gcc\x86_64-w64-mingw32\7.3.0"
"-LE:/msys/mingw64-64\x86_64-w64-mingw32\lib" "-LE:/msys/mingw64-64\lib"
"-LE:/msys/mingw64-64\x86_64-w64-mingw32/sys-root/mingw/lib" --icf=all
--gc-sections bin/pp.o bin/posix_main.o bin/pp/Script.o bin/pp/Execution.o
bin/pp/Variable.o bin/pp/Shell.o bin/pp/Database.o bin/pp/Type.o
bin/pp/parser/Utility.o -lpcfxx -lboost_program_options -lboost_locale
-lboost_filesystem -lboost_iostreams -lboost_date_time -lboost_thread
-lboost_regex -lboost_system -lpcf -lsqlite3 -lws2_32 -lstdc++ --start-group
-lmingw32 -lgcc -lmoldname -lmingwex -lpthread -lmsvcrt -ladvapi32 -lshell32
-luser32 -lkernel32 --end-group
"E:/msys/mingw64-64\lib\gcc\x86_64-w64-mingw32\7.3.0\crtend.o"

This resulted in a deadlock within lld. I re-executed all with drmemory and got
the output with invalid memory access errors (see attachment).

The used lld.exe executable with debug symbols can be found here:
<a href="https://www.sendspace.com/file/12dj2d">https://www.sendspace.com/file/12dj2d</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>