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

    <tr>
        <th>Summary</th>
        <td>
            llvm-profdata crash in llvm::report_bad_alloc_error
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          def-
      </td>
    </tr>
</table>

<pre>
    This is with large amounts of profraw files, trying to merge them:
```
(gdb) bt
#0  0x00007fc70d829387 in raise () from /lib64/libc.so.6
#1  0x00007fc70d82abb8 in abort () from /lib64/libc.so.6
#2  0x00007fc70e1e9ac5 in llvm::report_bad_alloc_error(char const*, bool) () from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#3  0x00007fc70e236119 in llvm::SmallVectorBase<unsigned long>::grow_pod(void*, unsigned long, unsigned long) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#4  0x00007fc70e1da666 in llvm::zlib::uncompress(llvm::StringRef, llvm::SmallVectorImpl<char>&, unsigned long) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#5  0x00007fc70ea28b3b in llvm::readPGOFuncNameStrings(llvm::StringRef, llvm::InstrProfSymtab&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#6  0x00007fc70ea35eba in llvm::RawInstrProfReader<unsigned long>::createSymtab(llvm::InstrProfSymtab&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#7  0x00007fc70ea355df in llvm::RawInstrProfReader<unsigned long>::readHeader(llvm::RawInstrProf::Header const&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#8  0x00007fc70ea35907 in llvm::RawInstrProfReader<unsigned long>::readNextHeader(char const*) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#9  0x00007fc70ea356f2 in llvm::RawInstrProfReader<unsigned long>::readNextRecord(llvm::NamedInstrProfRecord&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#10 0x00007fc70ea3362d in llvm::InstrProfIterator::Increment() () from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#11 0x000000000022719e in loadInput(WeightedFile const&, (anonymous namespace)::SymbolRemapper*, WriterContext*) ()
#12 0x00007fc70e2492e8 in void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, llvm::ThreadPool::ThreadPool(llvm::ThreadPoolStrategy)::$_0> >(void*) () from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#13 0x00007fc70e62bea5 in start_thread () from /lib64/libpthread.so.0
#14 0x00007fc70d8f1b0d in clone () from /lib64/libc.so.6
```
Another one, similar failure:
```
(gdb) bt
#0  0x00007f778c9ee387 in raise () from /lib64/libc.so.6
#1  0x00007f778c9efbb8 in abort () from /lib64/libc.so.6
#2  0x00007f778d3aeac5 in llvm::report_bad_alloc_error(char const*, bool) () from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#3  0x00007f778d3fb119 in llvm::SmallVectorBase<unsigned long>::grow_pod(void*, unsigned long, unsigned long) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#4  0x00007f778d39f666 in llvm::zlib::uncompress(llvm::StringRef, llvm::SmallVectorImpl<char>&, unsigned long) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#5  0x00007f778dbedb3b in llvm::readPGOFuncNameStrings(llvm::StringRef, llvm::InstrProfSymtab&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#6  0x00007f778dbfaeba in llvm::RawInstrProfReader<unsigned long>::createSymtab(llvm::InstrProfSymtab&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#7  0x00007f778dbfa5df in llvm::RawInstrProfReader<unsigned long>::readHeader(llvm::RawInstrProf::Header const&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#8  0x00007f778dbfa907 in llvm::RawInstrProfReader<unsigned long>::readNextHeader(char const*) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#9  0x00007f778dbfa6f2 in llvm::RawInstrProfReader<unsigned long>::readNextRecord(llvm::NamedInstrProfRecord&) ()
   from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#10 0x00007f778dbf862d in llvm::InstrProfIterator::Increment() () from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMProfileData.so.12
#11 0x000000000022719e in loadInput(WeightedFile const&, (anonymous namespace)::SymbolRemapper*, WriterContext*) ()
#12 0x00007f778d40e2e8 in void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, llvm::ThreadPool::ThreadPool(llvm::ThreadPoolStrategy)::$_0> >(void*) () from /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin/../lib/libLLVMSupport.so.12
#13 0x00007f778d7f0ea5 in start_thread () from /lib64/libpthread.so.0
#14 0x00007f778cab6b0d in clone () from /lib64/libc.so.6
```
Version:
```
$ clang --version
clang version 12.0.1 (https://github.com/yugabyte/llvm-project.git bdb147e675d8c87cee72cc1f87c4b82855977d94)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/yb-build/llvm/yb-llvm-v12.0.1-yb-1-1633099823-bdb147e6-centos7-x86_64/bin
```
I will check if I can provide a reproducer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztmVlv2zgQxz-N_ELIkKj7wQ9p0uwG6HaLtGgfDR4jm1tJ1FJUEu-n36FkO74aBM0eaWHDsCVqPOT8hsf8Ya7lavZpqTqC73tll6RiZgGE1bpvbEd0SVqjS8PuSakq6Dx6SaxZqWZBrCY1OFu7hNqLLrzgygsuvDRYv8dbmi8k92hBuN20RAEhwUOAr6wUWSBzWkR5RlRDDFMdEPyN-0FpdI3X15XiaTx-i2mnp-nWT3joh3GeOz-Ma2Of74fu-YEQCiYS56eq7obIogsDLbqccybnrKq0mIMx2mAPYskMEbrprEcvHB2udeW6Pehdt2hwveI-71Ul3TCc76HFXfl3IZ0G09DH-9AP0ygKiiKnkc8lD-MMUl9AY3WX-Q95Oh_i4KrBz-l0DGn8fPfu828f-9aN1YUY0m2M0X6MN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