From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hugh Wang <hghwng@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16348: Memory leak when parsing config
Date: Wed, 08 Apr 2020 15:25:49 -0400
Message-ID: <4653.1586373949@sss.pgh.pa.us> (raw)
In-Reply-To: <CACGj_g_CtJ0dF+-3DeO2ECn8SRLvQGXJoRMPtmwtysg5i4uvKQ@mail.gmail.com>
References: <16348-018c10b6fd16ebcc@postgresql.org>
<29582.1586272948@sss.pgh.pa.us>
<CACGj_g_CtJ0dF+-3DeO2ECn8SRLvQGXJoRMPtmwtysg5i4uvKQ@mail.gmail.com>
Hugh Wang <hghwng@gmail.com> writes:
> Even if I believe in LeakSanitizer, it's absolutely stupid to ignore the
> recommendations from an experienced developer. To really make sure that there's
> memory leak, I verified the leak with gdb. When ProcessConfigFile is entered, I
> set a breakpoint to print guc_strdup's return value ($rax) in
> set_config_sourcefile. I also set a breakpoint on free to print the argument
> ($rdi). To sum up: for any returned pointer ofguc_strdup, if a
> corresponding free
> cannot be found, then we can confirm that there's a leak.
[ shrug... ] Nonetheless, your analysis is faulty, because it's
experimentally demonstrable that there is no leak. I just left
a backend run for quite some time, hitting it with a stream of
SIGHUPs, and for good measure having it read the pg_file_settings view
over and over so that the show_all_file_settings code path is being
exercised as well. By now, if either of those code paths was leaking
even one single byte per execution, I could see the difference in "top".
But the process memory size is not moving.
I speculate that you may be confusing the transient ConfigVariable
data structures with the non-transient GUC storage (struct config_generic
and its overlays). The former data structure, including attached strings
such as filenames, is palloc'd in a short-lived memory context and we
get rid of it by dropping the context. The actual GUC storage is malloc'd
so we have to take care to free() any string we replace. As far as I can
tell, we do. set_config_sourcefile certainly does so.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, hghwng@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16348: Memory leak when parsing config
In-Reply-To: <4653.1586373949@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