Bug 469782

Summary: Valgrind does not support zstd-compressed debug sections
Product: [Developer tools] valgrind Reporter: Sam James <sam>
Component: generalAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal CC: kocelfc
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
See Also: https://bugs.kde.org/show_bug.cgi?id=303877
Latest Commit: Version Fixed In:

Description Sam James 2023-05-15 04:03:00 UTC
SUMMARY

Valgrind cannot read debug symbols compressed using zstd (e.g. objcopy --compress-debug-sections=zstd or gcc -gz=zstd ...).

Note that Valgrind *does* support zlib-compressed debug symbols.

STEPS TO REPRODUCE
1.  Build an application using `gcc -gz=zstd`, e.g.:
     echo 'int main(){}' | gcc -x c - -ggdb3 -gz=zstd -o /tmp/foo
2. valgrind /tmp/foo

OBSERVED RESULT
```
$ valgrind /tmp/foo
==3964496== Memcheck, a memory error detector
==3964496== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==3964496== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==3964496== Command: /tmp/foo
==3964496==
--3964496-- WARNING: Serious error when reading debug info
--3964496-- When reading debug info from /tmp/foo:
--3964496--    Compression type is unsupported
--3964496-- WARNING: Serious error when reading debug info
--3964496-- When reading debug info from /usr/libexec/valgrind/memcheck-amd64-linux:
--3964496--    Compression type is unsupported
==3964496==
==3964496== HEAP SUMMARY:
==3964496==     in use at exit: 0 bytes in 0 blocks
==3964496==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==3964496==
==3964496== All heap blocks were freed -- no leaks are possible
==3964496==
==3964496== For lists of detected and suppressed errors, rerun with: -s
==3964496== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```

EXPECTED RESULT

Successful use of Valgrind, i.e. Valgrind can parse zstd-compressed debug sections.

ADDITIONAL INFORMATION

See also:
- https://maskray.me/blog/2022-01-23-compressed-debug-sections
- https://maskray.me/blog/2022-09-09-zstd-compressed-debug-sections
- bug 303877 where zlib-compressed debug sections support was added to Valgrind