<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 - Crash in MarkLive"
   href="https://bugs.llvm.org/show_bug.cgi?id=45457">45457</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash in MarkLive
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>wasm
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sks_f@mail.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, sbc@chromium.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have crash in wasm-lld, here is stack trace:

 #4 0x00007f392408fb20 __restore_rt (/lib64/libpthread.so.0+0x14b20)
 #5 0x00007f3922856625 raise (/lib64/libc.so.6+0x3c625)
 #6 0x00007f392283f8d9 abort (/lib64/libc.so.6+0x258d9)
 #7 0x00007f392283f7a9 _nl_load_domain.cold (/lib64/libc.so.6+0x257a9)
 #8 0x00007f392284ea66 (/lib64/libc.so.6+0x34a66)
 #9 0x00007f3923fa1c58 lld::wasm::Symbol::markLive()
llvm_source/tools/lld/wasm/Symbols.cpp:129:40
#10 0x00007f3923f8f7e5 lld::wasm::(anonymous
namespace)::MarkLive::enqueue(lld::wasm::Symbol*)
llvm_source/tools/lld/wasm/MarkLive.cpp:65:40
#11 0x00007f3923f8fe5b lld::wasm::(anonymous namespace)::MarkLive::mark()
llvm_source/tools/lld/wasm/MarkLive.cpp:151:14
#12 0x00007f3923f8fc3d lld::wasm::(anonymous namespace)::MarkLive::run()
llvm_source/tools/lld/wasm/MarkLive.cpp:111:1
#13 0x00007f3923f8ff31 lld::wasm::markLive()
llvm_source/tools/lld/wasm/MarkLive.cpp:166:15
#14 0x00007f3923f4f4ec lld::wasm::(anonymous
namespace)::LinkerDriver::link(llvm::ArrayRef<char const*>)
llvm_source/tools/lld/wasm/Driver.cpp:792:14
#15 0x00007f3923f4ad25 lld::wasm::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&) llvm_source/tools/lld/wasm/Driver.cpp:93:3
#16 0x00000000004037fd main llvm_source/tools/lld/tools/lld/lld.cpp:160:12
#17 0x00007f39228411a3 __libc_start_main (/lib64/libc.so.6+0x271a3)

I was able to debug lld to see what's happening, so there is my observations:

Crash occurs because symbol is discarded due comdat. This symbol has local
binding (sym.isBindingLocal() == true) in InputFiles.cpp, It is created here
<a href="https://github.com/llvm/llvm-project/blob/aff75e1a1facbc6cc274070690ff3d725325c0f1/lld/wasm/InputFiles.cpp#L401">https://github.com/llvm/llvm-project/blob/aff75e1a1facbc6cc274070690ff3d725325c0f1/lld/wasm/InputFiles.cpp#L401</a>
as DefinedFunction (but discarded == true). 

Later, in MarkLive::run() some relocation has reference to this symbol and in
ASSERT(isDiscarded) cause this crash.

Is this bug in wasm-ld, that incorrectly handles isBindingLocal == true with
comdat or this is CodeGen bug, that incorrectly generates comdat for that
symbol ?
Is it legal to have isBindingLocal == true simultaneosly with comdat group?</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>