Description
llvm-dwarfdump crash repro with CREL:
$ cat main.cpp
bool bar();
int foo(int x) {
if (bar()) {
x = x * 2;
return x;
}
else {
x = x + 1;
return x;
}
}
$ clang++ -O1 -Wa,--crel,--allow-experimental-crel -g -c main.cpp && llvm-dwarfdump main.o
main.o: file format elf64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x00000055, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000059)
error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: insufficient space for 32 bit header prefix
0x0000000c: DW_TAG_compile_unit
DW_AT_producer ()
DW_AT_language (DW_LANG_C_plus_plus_14)
DW_AT_name ()
DW_AT_str_offsets_base (0x00000000)
DW_AT_stmt_list (0x00000000)
DW_AT_comp_dir ()
DW_AT_low_pc (0x0008000500000014)
DW_AT_high_pc (0x000800050000002a)
DW_AT_addr_base (0x00000000)
DW_AT_loclists_base (0x00000000)
0x00000027: DW_TAG_subprogram
DW_AT_low_pc (0x0008000500000014)
DW_AT_high_pc (0x000800050000002a)
DW_AT_frame_base (DW_OP_reg7 RSP)
DW_AT_call_all_calls (true)
DW_AT_linkage_name ()
DW_AT_name ()
DW_AT_decl_file ("/tmp")
DW_AT_decl_line (2)
DW_AT_type (0x00000054 "base ")
DW_AT_external (true)
0x00000037: DW_TAG_formal_parameter
DW_AT_location (indexed (0x0) loclist = 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 main.o
#0 0x000055f4e6e270a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x1ba80a8)
#1 0x000055f4e6e24cae llvm::sys::RunSignalHandlers() (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x1ba5cae)
#2 0x000055f4e6e278c1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f9adcc49df0 (/lib/x86_64-linux-gnu/libc.so.6+0x3fdf0)
#4 0x000055f4e6a4c86f llvm::DWARFUnit::getLoclistOffset(unsigned int) (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x17cd86f)
#5 0x000055f4e6a36dba dumpLocationList(llvm::raw_ostream&, llvm::DWARFFormValue const&, llvm::DWARFUnit*, unsigned int, llvm::DIDumpOptions) DWARFDie.cpp:0:0
#6 0x000055f4e6a35980 dumpAttribute(llvm::raw_ostream&, llvm::DWARFDie const&, llvm::DWARFAttribute const&, unsigned int, llvm::DIDumpOptions) DWARFDie.cpp:0:0
#7 0x000055f4e6a342e4 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x17b52e4)
#8 0x000055f4e6a3473a llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x17b573a)
#9 0x000055f4e6a3473a llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x17b573a)
#10 0x000055f4e6a504e8 llvm::DWARFCompileUnit::dump(llvm::raw_ostream&, llvm::DIDumpOptions) (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x17d14e8)
#11 0x000055f4e69f519c llvm::DWARFContext::dump(llvm::raw_ostream&, llvm::DIDumpOptions, std::array<std::optional<unsigned long>, 28ul>)::$_1::operator()(char const*, llvm::iterator_range<std::unique_ptr<llvm::DWARFUnit, std::default_delete<llvm::DWARFUnit>>*>) const DWARFContext.cpp:0:0
#12 0x000055f4e69eeb42 llvm::DWARFContext::dump(llvm::raw_ostream&, llvm::DIDumpOptions, std::array<std::optional<unsigned long>, 28ul>) (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x176fb42)
#13 0x000055f4e69d6def dumpObjectFile(llvm::object::ObjectFile&, llvm::DWARFContext&, llvm::Twine const&, llvm::raw_ostream&) llvm-dwarfdump.cpp:0:0
#14 0x000055f4e69d8cd6 handleBuffer(llvm::StringRef, llvm::MemoryBufferRef, std::function<bool (llvm::object::ObjectFile&, llvm::DWARFContext&, llvm::Twine const&, llvm::raw_ostream&)>, llvm::raw_ostream&) llvm-dwarfdump.cpp:0:0
#15 0x000055f4e69d3a27 handleFile(llvm::StringRef, std::function<bool (llvm::object::ObjectFile&, llvm::DWARFContext&, llvm::Twine const&, llvm::raw_ostream&)>, llvm::raw_ostream&) llvm-dwarfdump.cpp:0:0
#16 0x000055f4e69d3652 main (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x1754652)
#17 0x00007f9adcc33ca8 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#18 0x00007f9adcc33d65 call_init ./csu/../csu/libc-start.c:128:20
#19 0x00007f9adcc33d65 __libc_start_main ./csu/../csu/libc-start.c:347:5
#20 0x000055f4e69c0841 _start (/usr/local/google/home/zequanwu/work/llvm-project/out/cmake/bin/llvm-dwarfdump+0x1741841)
[2] 675271 segmentation fault (core dumped) llvm-dwarfdump main.o
It's crashed here because LocTable
failed to initialize due to not handling CREL.