| Summary: | Unclosed leak_summary/still_reachable tag in xml output | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | moneill |
| Component: | memcheck | Assignee: | Paul Floyd <pjfloyd> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | mark, pjfloyd |
| Priority: | NOR | ||
| Version First Reported In: | 3.26.0 | ||
| Target Milestone: | --- | ||
| Platform: | RedHat Enterprise Linux | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
Oops. Seems to have been accidentally introduced by: commit 7786b075abef51ca3d84b9717915f04b32950b32 Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Sun May 11 15:41:10 2025 +0200 Bug 390310 - Output summaries in XML files Original patch contributed by renaultd@free.fr It seems to be missing the closing tag: diff --git a/memcheck/mc_leakcheck.c b/memcheck/mc_leakcheck.c index 586bff448bfb..4df0b180d5d1 100644 --- a/memcheck/mc_leakcheck.c +++ b/memcheck/mc_leakcheck.c @@ -1768,7 +1768,8 @@ static void print_results(ThreadId tid, LeakCheckParams* lcp) umsg_or_xml(VG_(clo_xml) ? " <still_reachable>\n" " <bytes>%'lu%s</bytes>\n" - " <blocks>%'lu%s</blocks>\n" : + " <blocks>%'lu%s</blocks>\n" + " </still_reachable>\n" : " still reachable: %'lu%s bytes in %'lu%s blocks\n", MC_(bytes_reachable), DBY (MC_(bytes_reachable), old_bytes_reachable), Thanks for the report. How did you notice the error? Did a tool like a linter or an IDE report something? Also this was all my fault, the error wasn't in the original patch and must have occurred when I rebased and/or reformatted the patch. None of the tests cover this. When I was testing there were large numbers of xml diffs, mainly due to <suppressed> which is highly platform-dependent. I'll add some platform-specific tests (probably on Linux which is the most stable with glibc freeres). And maybe a test using xmllint in post. (In reply to Paul Floyd from comment #2) > Thanks for the report. > > How did you notice the error? Did a tool like a linter or an IDE report > something? No problem. We have valgrind integrated into our CI/CD system and the parser is crashing out on the XML from 3.26. I'll see if I can add some tests that use xmllint. commit 758b0f55e878fd7bd9dcd1ff3e74f10a7a00a771 Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Thu Jan 15 08:44:52 2026 +0100 Bug 514613 - Unclosed leak_summary/still_reachable tag in xml output |
SUMMARY When running valgrind (memcheck) on an binary with a memory issue (e.g. definitely lost, or still reachable) the still_reachable tag in the leak_summary section is not closed. This was observed with valgrind 3.26.0 and 3.26.1 releases, but not with 3.25.1 STEPS TO REPRODUCE 1. Create simple leaky program: leak.c #include <stdlib.h> int main(int, char**) { int *p = malloc(sizeof(int)); return 0; } 2. Build and valgrind gcc foo.c -o foo && valgrind --leak-check=full --show-reachable=yes --xml=yes --xml-fd=0 ./foo OBSERVED RESULT The leak summary has an unclosed still_reachable tag. <leak_summary> <definitely_lost> <bytes>4</bytes> <blocks>1</blocks> </definitely_lost> <indirectly_lost> <bytes>0</bytes> <blocks>0</blocks> </indirectly_lost> <possibly_lost> <bytes>0</bytes> <blocks>0</blocks> </possibly_lost> <still_reachable> <bytes>0</bytes> <blocks>0</blocks> <suppressed> <bytes>0</bytes> <blocks>0</blocks> </suppressed> </leak_summary> EXPECTED RESULT The still_reachable tag should be closed, making the XML valid <still_reachable> <bytes>0</bytes> <blocks>0</blocks> </still_reachable> SOFTWARE/OS VERSIONS Linux/KDE Plasma: RedHat9