Re: Why our Valgrind reports suck

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Why our Valgrind reports suck
Date: 2025-05-11 19:10:53
Message-ID: 1118882.1746990653@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> And, since there's nothing new under the sun around here,
> we already had a discussion about that back in 2021:
> https://www.postgresql.org/message-id/flat/3471359.1615937770%40sss.pgh.pa.us
> That thread seems to have led to fixing some specific bugs,
> but we never committed any of the discussed valgrind infrastructure
> improvements. I'll have a go at resurrecting that...

Okay, here is a patch series that updates the
0001-Make-memory-contexts-themselves-more-visible-to-valg.patch
patch you posted in that thread, and makes various follow-up
fixes that either fix or paper over various leaks. Some of it
is committable I think, but other parts are just WIP. Anyway,
as of the 0010 patch we can run through the core regression tests
and see no more than a couple of kilobytes total reported leakage
in any process, except for two tests that expose leaks in TS
dictionary building. (That's fixable but I ran out of time,
and I wanted to get this posted before Montreal.) There is
work left to do before we can remove the suppressions added in
0002, but this is already huge progress compared to where we were.

A couple of these patches are bug fixes that need to be applied and
even back-patched. In particular, I had not realized that autovacuum
leaks a nontrivial amount of memory per relation processed (cf 0009),
and apparently has done for a few releases now. This is horrid in
databases with many tables, and I'm surprised that we've not gotten
complaints about it.

regards, tom lane

Attachment Content-Type Size
v1-0001-Improve-our-support-for-Valgrind-s-leak-tracking.patch text/x-diff 17.9 KB
v1-0002-Temporarily-suppress-some-Valgrind-complaints.patch text/x-diff 2.3 KB
v1-0003-Silence-complaints-about-leaked-dynahash-storage.patch text/x-diff 4.6 KB
v1-0004-Silence-complaints-about-leaked-catcache-entries.patch text/x-diff 2.7 KB
v1-0005-Silence-complaints-about-leaked-CatCache-structs.patch text/x-diff 1.8 KB
v1-0006-Silence-complaints-about-save_ps_display_args.patch text/x-diff 1.7 KB
v1-0007-Don-t-leak-the-startup-packet-buffer-in-ProcessSt.patch text/x-diff 1.9 KB
v1-0008-Fix-some-extremely-broken-code-from-525392d57.patch text/x-diff 2.5 KB
v1-0009-Avoid-per-relation-leakage-in-autovacuum.patch text/x-diff 4.7 KB
v1-0010-Silence-complaints-about-leaks-in-load_domaintype.patch text/x-diff 2.5 KB
v1-0011-WIP-reduce-leakages-during-PL-pgSQL-function-comp.patch text/x-diff 6.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-05-11 19:33:30 Re: Why our Valgrind reports suck
Previous Message Pierre Barre 2025-05-11 18:30:34 Re: FileFallocate misbehaving on XFS