pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Getting better results from valgrind leak tracking
Date: Wed, 17 Mar 2021 21:30:48 -0400
Message-ID: <3662652.1616031048@sss.pgh.pa.us> (raw)
In-Reply-To: <20210318002656.7fezwucw4qdlivzk@alap3.anarazel.de>
References: <3471359.1615937770@sss.pgh.pa.us>
	<20210317023101.anvejcfotwka6gaa@alap3.anarazel.de>
	<3479700.1615950107@sss.pgh.pa.us>
	<cea52c41-f005-4ec3-8dd8-4d12dbfbe9f6@www.fastmail.com>
	<20210317055718.v6qs3ltzrformqoa@alap3.anarazel.de>
	<3508520.1615990604@sss.pgh.pa.us>
	<3c52ffa1-d46d-4838-9e67-a9760399ecee@www.fastmail.com>
	<20210317181531.7oggpqevzz6bka3g@alap3.anarazel.de>
	<3617762.1616018856@sss.pgh.pa.us>
	<20210318002656.7fezwucw4qdlivzk@alap3.anarazel.de>

Andres Freund <andres@anarazel.de> writes:
> On 2021-03-17 18:07:36 -0400, Tom Lane wrote:
>> Huh, interesting.  I wonder why that makes the ident problem go away?

> I spent a bit of time looking at valgrind, and it looks to be explicit
> behaviour:
>
>    // Our goal is to construct a set of chunks that includes every
>    // mempool chunk, and every malloc region that *doesn't* contain a
>    // mempool chunk.

Ugh.

> I guess that makes sense, but would definitely be nice to have had
> documented...

Indeed.  So this started happening to us when we merged the aset
header with its first allocation block.

>>> There are a few leak warnings around guc.c that look like they might be
>>> real, not false positives, and thus a bit concerning. Looks like several
>>> guc check hooks don't bother to free the old *extra before allocating a
>>> new one.

>> I'll take a look, but I'm pretty certain that guc.c, not the hooks, is
>> responsible for freeing those.

I believe I've just tracked down the cause of that.  Those errors
are (as far as I've seen) only happening in parallel workers, and
the reason is this gem in RestoreGUCState:

	/* See comment at can_skip_gucvar(). */
	for (i = 0; i < num_guc_variables; i++)
		if (!can_skip_gucvar(guc_variables[i]))
			InitializeOneGUCOption(guc_variables[i]);

where InitializeOneGUCOption zeroes out that GUC variable, causing
it to lose track of any allocations it was responsible for.

At minimum, somebody didn't understand the difference between "initialize"
and "reset".  But I suspect we could just nuke this loop altogether.
I've not yet tried to grok the comment that purports to justify it,
but I fail to see why it'd ever be useful to drop values inherited
from the postmaster.

			regards, tom lane





view thread (23+ messages)  latest in thread

Message-ID: <3662652.1616031048@sss.pgh.pa.us>
Permalink:  ../3662652.1616031048@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3662652.1616031048@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de
  Subject: Re: Getting better results from valgrind leak tracking
  In-Reply-To: <3662652.1616031048@sss.pgh.pa.us>
  References: <3471359.1615937770@sss.pgh.pa.us> <20210317023101.anvejcfotwka6gaa@alap3.anarazel.de> <3479700.1615950107@sss.pgh.pa.us> <cea52c41-f005-4ec3-8dd8-4d12dbfbe9f6@www.fastmail.com> <20210317055718.v6qs3ltzrformqoa@alap3.anarazel.de> <3508520.1615990604@sss.pgh.pa.us> <3c52ffa1-d46d-4838-9e67-a9760399ecee@www.fastmail.com> <20210317181531.7oggpqevzz6bka3g@alap3.anarazel.de> <3617762.1616018856@sss.pgh.pa.us> <20210318002656.7fezwucw4qdlivzk@alap3.anarazel.de> <3662652.1616031048@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox