llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.06k stars 11.59k forks source link

llvm-dwarfdump segmentation fault in llvm::DWARFUnit::getLoclistOffset(unsigned int) #85900

Open molar opened 6 months ago

molar commented 6 months ago

Hello

I encountered a crash in llvm-dwarfdump while investigating why llvm-dwp produces invalid dwp files. I have a minimal reproducible example here https://github.com/molar/dwp_merging_repro using llvm 18, i also tried with llvm 16 and it has the same issue.

The crash is

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llvm-dwarfdump-18 --verify main_binary_that_crashes.dwp
 #0 0x00007fe6aaeed7d6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd937d6)
 #1 0x00007fe6aaeeb790 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd91790)
 #2 0x00007fe6aaeede9b (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd93e9b)
 #3 0x00007fe6a9d2e520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fe6ac889b7d llvm::DWARFUnit::getLoclistOffset(unsigned int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x272fb7d)
 #5 0x00007fe6ac874334 llvm::DWARFDie::getLocations(llvm::dwarf::Attribute) const (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x271a334)
 #6 0x00007fe6ac88c8a2 llvm::DWARFVerifier::verifyDebugInfoAttribute(llvm::DWARFDie const&, llvm::DWARFAttribute&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so
.18.1+0x27328a2)
 #7 0x00007fe6ac88bddd llvm::DWARFVerifier::verifyUnitContents(llvm::DWARFUnit&, std::map<unsigned long, std::set<unsigned long, std::less<unsigned long>,
 std::allocator<unsigned long>>, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::set<unsigned long, std::less<unsigned long>,
 std::allocator<unsigned long>>>>>&, std::map<unsigned long, std::set<unsigned long, std::less<unsigned long>, std::allocator<unsigned long>>, std::less<u
nsigned long>, std::allocator<std::pair<unsigned long const, std::set<unsigned long, std::less<unsigned long>, std::allocator<unsigned long>>>>>&) (/usr/l
ib/llvm-18/bin/../lib/libLLVM.so.18.1+0x2731ddd)
 #8 0x00007fe6ac88f771 llvm::DWARFVerifier::verifyUnits(llvm::DWARFUnitVector const&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x2735771)
 #9 0x00007fe6ac890c3c llvm::DWARFVerifier::handleDebugInfo() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x2736c3c)
#10 0x00007fe6ac83ead8 llvm::DWARFContext::verify(llvm::raw_ostream&, llvm::DIDumpOptions) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x26e4ad8)
#11 0x0000559f57971c27 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x17c27)
#12 0x0000559f57975377 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x1b377)
#13 0x0000559f57971a08 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x17a08)
#14 0x0000559f57971359 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x17359)
#15 0x00007fe6a9d15d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#16 0x00007fe6a9d15e40 call_init ./csu/../csu/libc-start.c:128:20
#17 0x00007fe6a9d15e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#18 0x0000559f57964835 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0xa835)
./build.sh: line 23: 471893 Segmentation fault      $DWARFDUMP --verify main_binary_that_crashes.dwp

I hope that you can also shed some light on why the llvm-dwp tool does not generate a valid DWP file and help me file another issue on it.

llvmbot commented 6 months ago

@llvm/issue-subscribers-debuginfo

Author: Morten larsen (molar)

Hello I encountered a crash in ``llvm-dwarfdump`` while investigating why ``llvm-dwp`` produces invalid dwp files. I have a minimal reproducible example here https://github.com/molar/dwp_merging_repro using llvm 18, i also tried with llvm 16 and it has the same issue. The crash is ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: llvm-dwarfdump-18 --verify main_binary_that_crashes.dwp #0 0x00007fe6aaeed7d6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd937d6) #1 0x00007fe6aaeeb790 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd91790) #2 0x00007fe6aaeede9b (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd93e9b) #3 0x00007fe6a9d2e520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #4 0x00007fe6ac889b7d llvm::DWARFUnit::getLoclistOffset(unsigned int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x272fb7d) #5 0x00007fe6ac874334 llvm::DWARFDie::getLocations(llvm::dwarf::Attribute) const (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x271a334) #6 0x00007fe6ac88c8a2 llvm::DWARFVerifier::verifyDebugInfoAttribute(llvm::DWARFDie const&, llvm::DWARFAttribute&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so .18.1+0x27328a2) #7 0x00007fe6ac88bddd llvm::DWARFVerifier::verifyUnitContents(llvm::DWARFUnit&, std::map<unsigned long, std::set<unsigned long, std::less<unsigned long>, std::allocator<unsigned long>>, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::set<unsigned long, std::less<unsigned long>, std::allocator<unsigned long>>>>>&, std::map<unsigned long, std::set<unsigned long, std::less<unsigned long>, std::allocator<unsigned long>>, std::less<u nsigned long>, std::allocator<std::pair<unsigned long const, std::set<unsigned long, std::less<unsigned long>, std::allocator<unsigned long>>>>>&) (/usr/l ib/llvm-18/bin/../lib/libLLVM.so.18.1+0x2731ddd) #8 0x00007fe6ac88f771 llvm::DWARFVerifier::verifyUnits(llvm::DWARFUnitVector const&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x2735771) #9 0x00007fe6ac890c3c llvm::DWARFVerifier::handleDebugInfo() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x2736c3c) #10 0x00007fe6ac83ead8 llvm::DWARFContext::verify(llvm::raw_ostream&, llvm::DIDumpOptions) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0x26e4ad8) #11 0x0000559f57971c27 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x17c27) #12 0x0000559f57975377 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x1b377) #13 0x0000559f57971a08 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x17a08) #14 0x0000559f57971359 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0x17359) #15 0x00007fe6a9d15d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #16 0x00007fe6a9d15e40 call_init ./csu/../csu/libc-start.c:128:20 #17 0x00007fe6a9d15e40 __libc_start_main ./csu/../csu/libc-start.c:379:5 #18 0x0000559f57964835 (/usr/lib/llvm-18/bin/llvm-dwarfdump+0xa835) ./build.sh: line 23: 471893 Segmentation fault $DWARFDUMP --verify main_binary_that_crashes.dwp ``` I hope that you can also shed some light on why the ``llvm-dwp`` tool does not generate a valid DWP file and help me file another issue on it.