https://bugs.kde.org/show_bug.cgi?id=492663
Bug ID: 492663 Summary: Valgrind ignores debug info for some binaries Classification: Developer tools Product: valgrind Version: 3.24 GIT Platform: Other OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: general Assignee: jsew...@acm.org Reporter: m...@glandium.org Target Milestone: --- Created attachment 173332 --> https://bugs.kde.org/attachment.cgi?id=173332&action=edit Test case archive (.tar.bz2) SUMMARY Some binary layouts make it so that valgrind ignores their debug info. STEPS TO REPRODUCE 1. Download and unpack the attached test case archive 2. run `valgrind --leak-check=full testcase/firefox-bad` on Linux x86_64. OBSERVED RESULT A leak is reported with the second frame non-symbolicated EXPECTED RESULT The second frame should be symbolicated ADDITIONAL INFORMATION The archive also contains a `firefox-good` binary that does get the second frame symbolicated. The only difference in the source code between `firefox-bad` and `firefox-good` is the content and length of a single string. It's enough to push the boundaries of PT_LOADs to a place that makes `check_elf_and_get_rw_loads` not agree with how coregrind handles segments-merges on mmap, leading `di_notify_mmap` to bail with `no dinfo loaded firefox-bad (no rx or no rw mapping)` on the last firefox-bad segment, and the debug info not being loaded, ultimately leading to the lack of symbolication. The following patch "fixes" this problem: ``` diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 735f83044..326a1c59d 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -3954,7 +3954,6 @@ Bool ML_(check_elf_and_get_rw_loads) ( Int fd, const HChar* filename, Int * rw_l * with or without rounding up. * */ if (previous_rw_a_phdr.p_memsz > 0 && - ehdr_m.e_type == ET_EXEC && previous_rw_a_phdr.p_vaddr + previous_rw_a_phdr.p_filesz == a_phdr.p_vaddr) { ``` but the whole ordeal is incredibly fragile and making assumptions that I'm sure future linkers and/or dynamic loaders will keep breaking. -- You are receiving this mail because: You are watching all bug changes.