Bug 302901 - Valgrind crashes with dwz optimized debuginfo
Summary: Valgrind crashes with dwz optimized debuginfo
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.7 SVN
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 298870 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-07-02 14:19 UTC by Jakub Jelinek
Modified: 2023-10-12 15:52 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
valgrind-dwz-1.patch (27.82 KB, patch)
2012-07-02 14:20 UTC, Jakub Jelinek
Details
valgrind-dwz-2.patch (38.14 KB, patch)
2012-07-03 11:38 UTC, Jakub Jelinek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2012-07-02 14:19:20 UTC
Fedora 18 now uses the DWZ tool to decrease size of debug info:
https://fedoraproject.org/wiki/Features/DwarfCompressor
http://sourceware.org/git/?p=dwz.git;a=summary
This introduces two new forms into DWARF, and .gnu_debugaltlink sections (from either original ELF file or its separate debuginfo file) optionally pointing to an alternate debuginfo file, which is a mere ET_REL file with .debug_{info,str,line,abbrev} sections and .note.gnu.build-id.

Reproducible: Always

Steps to Reproduce:
Grab dwz from the above mentioned repository, build it.
Then say
cp -a varinfo1{,_1}; cp -a varinfo1{,_2}
dwz -m varinfo1.dwz varinfo1_{1,2}
and add a /usr/lib/debug/.build-id/xx/yyyyyy...yy.debug symlink (readelf -Wa varinfo1.dwz prints
the build-id at the end).
Then running valgrind --tool=memcheck --read-var-info=yes -q ./varinfo1_1 will show some of the issues.  Note, in F18 rpm's scripts take care of running dwz automatically.
Comment 1 Jakub Jelinek 2012-07-02 14:20:48 UTC
Created attachment 72281 [details]
valgrind-dwz-1.patch

WIP patch (needs actual handling of the DW_FORM_GNU_ref_alt references and possibly also
adding support for DW_TAG_partial_unit and/or DW_TAG_imported_unit).
Comment 2 Jakub Jelinek 2012-07-02 14:21:45 UTC
OT, glibc 2.16 has just been released and Fedora 18 is likely going to use it (if not 2.17), so it would be nice if valgrind 3.8.0 also supported glibc 2.16 out of the box in configury.
Comment 3 Jakub Jelinek 2012-07-03 11:38:35 UTC
Created attachment 72306 [details]
valgrind-dwz-2.patch

Updated patch.  Th emain remaining problem seems to be in that partial units, as the standard allows, aren't self-contained, they usually don't have DW_AT_language attribute, thus the type parsing code sees ->language == '?' and doesn't add the right implicit lower bounds to the array bounds.  What perhaps could be done is look through the DW_TAG_imported_unit DW_AT_import references and recursively mark the language kind of the partial units (in the usual case that a partial unit has all (possibly indirect) references from CUs of the same language kind, that language kind could be used, otherwise one would need to defer that decision at the point where a type is actually used.

In any case, I think the patch is an incremental progress, at least valgrind won't crash on such debuginfo.
Comment 4 Julian Seward 2012-07-05 13:20:30 UTC
Looks good to me.  Will push into trunk in the next few days.  If you have
any improved version I'll take that too :-)
Comment 5 Julian Seward 2012-07-14 10:00:40 UTC
(In reply to comment #3)
> Created attachment 72306 [details]
> valgrind-dwz-2.patch

Committed, with small fix (removal of inner declaration) to fix this:

m_debuginfo/readelf.c: In function ‘vgModuleLocal_read_elf_debug_info’:
m_debuginfo/readelf.c:2522: warning: declaration of ‘j’ shadows a previous local
m_debuginfo/readelf.c:1317: warning: shadowed declaration is here

Thanks for the patch.  Do you want to close this bug now and put followup patches
on a new bug, or keep this one open?
Comment 6 Julian Seward 2012-07-14 10:02:41 UTC
(In reply to comment #5)
> Committed, with small fix (removal of inner declaration) to fix this:
r12742, I forgot to mention.
Comment 7 Julian Seward 2012-07-14 10:08:13 UTC
(In reply to comment #2)
> OT, glibc 2.16 has just been released and Fedora 18 is likely going to use

Can you try with >= r12473 -- this allows the configure script to accept glibc-2.16.
Comment 8 Julian Seward 2012-07-14 10:19:11 UTC
*** Bug 298870 has been marked as a duplicate of this bug. ***