<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70184>70184</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Segmentation fault in llvm-lto
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          aytekinar
      </td>
    </tr>
</table>

<pre>
    Hi,

I receive a segmentation fault when running `llvm-lto -thinlto -thinlto-action=thinlink ...`.

Note that I am not running this command myself --- it's part of the `Makefile` of a PostgreSQL extension, and the corresponding PostgreSQL instance has been built with `--enable-llvm` configuration option.

I have modified the `Makefile` to include `PG_LDFLAGS += -Wl,--reproduce=repro.tar.gz` and am attaching [repro.tar.gz](https://github.com/llvm/llvm-project/files/13163675/repro.tar.gz) in this issue. The trace is as follows:

```cmd
0.      Program arguments: /usr/lib/llvm-15/bin/llvm-lto -thinlto -thinlto-action=thinlink -o vector.index.bc vector/src/hnsw.bc vector/src/hnswbuild.bc vector/src/hnswinsert.bc vector/src/hnswscan.bc vector/src/hnswutils.bc vector/src/hnswvacuum.bc vector/src/ivfbuild.bc vector/src/ivfflat.bc vector/src/ivfinsert.bc vector/src/ivfkmeans.bc vector/src/ivfscan.bc vector/src/ivfutils.bc vector/src/ivfvacuum.bc vector/src/vector.bc
 #0 0x00007f53ade7e3b1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf043b1)
 #1 0x00007f53ade7c0fe llvm::sys::RunSignalHandlers() (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf020fe)
 #2 0x00007f53ade7e8d6 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf048d6)
 #3 0x00007f53aca58520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f53ae8f7e2a (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0x197de2a)
 #5 0x00007f53ae8f59b2 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0x197b9b2)
 #6 0x00007f53ae8d3fe4 llvm::BitcodeWriter::writeIndex(llvm::ModuleSummaryIndex const*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>>>>> const*) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0x1959fe4)
 #7 0x00007f53ae8d4627 llvm::writeIndexToFile(llvm::ModuleSummaryIndex const&, llvm::raw_ostream&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>>>>> const*) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0x195a627)
 #8 0x0000562e5e4a9bea (/usr/lib/llvm-15/bin/llvm-lto+0x15bea)
 #9 0x0000562e5e4a32a5 (/usr/lib/llvm-15/bin/llvm-lto+0xf2a5)
#10 0x00007f53aca3fd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#11 0x00007f53aca3fe40 call_init ./csu/../csu/libc-start.c:128:20
#12 0x00007f53aca3fe40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#13 0x0000562e5e49e055 (/usr/lib/llvm-15/bin/llvm-lto+0xa055)
Segmentation fault
make: *** [/home/aytekinar/.pgenv/pgsql-16.0/lib/pgxs/src/makefiles/pgxs.mk:242: install] Error 139
```

Cc: @aykut-bozkurt
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWF9v47gR_zT0CyGBov5YevCDE5_3FsgWabO4ezQoaiSxpkiXpBznPn1BKf4jx25328UBLTYQYpJD_uY3w9GIHGataBTAAqUPKF3NWO9abRbszcFWKGZmpa7eFr8KRB8RWSGyHP9_xgY4iD1ghi00HSjHnNAK16yXDr-2oLDplRKqwSgjUu67QDqNA9cKddkIGPfrULwaBoTa4jAMUUbCS3V_0Q6wa5nDnzHrsNLuhO5aYTHXXcdUhbs3C7LGQRBg4RCdW7xjxmFdY9eCJ_KFbaEWElBG_CjDz9q6xsDLX58wHBwo68nQR-zR_BqujQG706ryyi5mC2UdUxxwyywuARQue-FNF671moIAFCslBN52r45rVYumN6Of9M7_hFOftmwPuNOVqAVUtyg7jYXisq8GyfOnzdNq_bT89IIRfUDxCge_S0Qfg8DAzuiq54Di1dAOHTNh84fH8JaxDjPnGG-H_UkfJnPSFaJ569zOoniJ6BrRdSNc25ch1x2i68Gg8SfYGf134A7RtadoEV1HcZTF2TxFdD1BpQUWatwtYW0PIf7aAnaGccDCYmZxraXUr4PSC6-gjIwP76pxhIR4-Hs2ujHeEtP0PgD9SozourfG0xPlkWTkyZRCHfvfGoiBxnvgTptQqAoOYcnf-4iureGIrltlX-8M-2io7siEsmDcHaHlTN0R9U5Ie0e2Z7zvuxtCsa_vcRH7upbsFhGxr--SFPt62wFTt5iIfX2Hv9jX9-iLfX2X_fsGlHzce4xoTDA5EELI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