Bug 457412

Summary: Valgrind does not read properly DWARF2 as generated by Clang14
Product: [Developer tools] valgrind Reporter: Jonathan DUFOUR <jojo19.duf>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: normal CC: mark
Priority: NOR    
Version: 3.19.0   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Source code to compile with -g to trigger the valgrind error

Description Jonathan DUFOUR 2022-08-02 13:55:31 UTC
Created attachment 151073 [details]
Source code to compile with -g to trigger the valgrind error

Encountered the same issue as the one described in this report: https://bugs.kde.org/show_bug.cgi?id=452758,
except that it's with DWARF2 in my case.
Also, it appears that the problem occurs only when compiling with at least one of the following flags: -g, -g1, -g2, -g3.
I'm using clang 14.0.6.

# Steps to reproduce
1. Compile any source code using clang 14.0.6, with one of the listed flags above (I have attached a simple hello.cpp that print the timeless Hello World, for those who haven't anything to compile).
2. Using the version 3.19.0, run valgrind on the created executable.
3. It would result in that kind of output

==13063== Memcheck, a memory error detector
==13063== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==13063== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==13063== Command: ./hello.out
==13063== 
### unhandled dwarf2 abbrev form code 0x25
### unhandled dwarf2 abbrev form code 0x25
### unhandled dwarf2 abbrev form code 0x25
### unhandled dwarf2 abbrev form code 0x23
==13063== Valgrind: debuginfo reader: ensure_valid failed:
==13063== Valgrind:   during call to ML_(img_get)
==13063== Valgrind:   request for range [24662751, +4) exceeds
==13063== Valgrind:   valid image size of 32360 for image:
==13063== Valgrind:   "/home/jodufour/Documents/42/Cursus/Projects/cpp_module_00/hello.out"
==13063== 
==13063== Valgrind: debuginfo reader: Possibly corrupted debuginfo file.
==13063== Valgrind: I can't recover.  Giving up.  Sorry.
==13063==
Comment 1 Mark Wielaard 2022-08-03 17:12:29 UTC
Those are DW_FORM_strx1 and DW_FORM_strx2 which are generated by clang for DWARF5.
So this is a duplicate of bug #452758

Note that -g1 -g2 etc are the "verbosity" of the DWARF not the version.
To change the version use -gdwarf-4

*** This bug has been marked as a duplicate of bug 452758 ***