This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/22215] New: Triggered assert at dwarf2read.c:10986 elf_section_nr < dwp_file->num_sections
- From: "alexander.v.shaposhnikov at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 27 Sep 2017 00:00:30 +0000
- Subject: [Bug gdb/22215] New: Triggered assert at dwarf2read.c:10986 elf_section_nr < dwp_file->num_sections
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=22215
Bug ID: 22215
Summary: Triggered assert at dwarf2read.c:10986 elf_section_nr
< dwp_file->num_sections
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: alexander.v.shaposhnikov at gmail dot com
Target Milestone: ---
This assert triggers if the section .strtab is the first one
(probably, more generally (but i didn't verify that), the same issue can come
up if .strtab is not the last section.
Example:
main.cpp:
struct Foo {
int bar;
};
int main() {
Foo foo;
foo.bar = 1;
int x = foo.bar + 1;
return x;
}
build commands:
g++ -fPIC -gsplit-dwarf -g -O0 main.cpp -o main.exe
llvm-dwp main.dwo -o main.exe.dwp
llvm-dwp (built from LLVM upstream, or, alternatively,
5.0 version should work as well)
places .strtab section at the beginning of the binary:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .strtab STRTAB 0000000000000000 000002a0
0000000000000053 0000000000000000 0 0 1
Next one needs to build GDB from the upstream + make sure the patch
https://sourceware.org/ml/gdb-patches/2017-09/msg00814.html is included
(it fixes a separate issue, otherwise gdb will segfault much earlier).
run gdb:
gdb
and see
(gdb) file main.exe
Reading symbols from main.exe...dwarf2read.c:10986: internal-error: void
dwarf2_locate_common_dwp_sections(bfd*, asection*, void*): Assertion
`elf_section_nr < dwp_file->num_sections' failed.
A problem internal to GDB has been detected,
Some remarks:
1. To workaround this issue one can use the following trick:
objcopy --remove-section .strtab main.exe.dwp
objcopy will remove ".strtab" section but will create a new section ".shstrtab"
and will put it at the end. GDB works fine with the newly created .dwp.
2. It looks like that the value of
dwp_file->num_sections is not correct. I didn't dig deep into this issue, but
one potential scenario might look as follows (i'm not sure, it's just a guess,
might be completely wrong):
in the file elf.c, inside the function
bfd_section_from_shdr (bfd *abfd, unsigned int shindex),
at the line 2242, case SHT_STRTAB:
for the section .strtab the function _bfd_elf_make_section_from_shdr is not
called
=> the function bfd_section_init is not called => abfd->section_count is not
incremented.
--
You are receiving this mail because:
You are on the CC list for the bug.