| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Henrik TJ <henrik(at)0x48(dot)dk>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Fix memory leak in postmasterMain |
| Date: | 2026-04-22 17:55:36 |
| Message-ID: | mwikkx643zp3f5qmx27crf2d2ngwgupc4om4kfq4gyc6vukjom@kyimpnconhdv |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On 2026-04-23 00:29:29 +0900, Fujii Masao wrote:
> On Wed, Apr 22, 2026 at 3:46 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
> >
> > From my experience, most of the time the postmaster is started with -D. On Linux and macOS, that path can be quite long, PATH_MAX is often 4096 on many Unix-like systems, and I am not sure about Windows. So I think this leak is worth fixing.
>
> We can also free()/pfree() userDoption in postgres.c and bootstrap.c?
>
> Since userDoption typically uses only a small amount of memory, I'm not sure
> this patch provides much practical benefit from a memory-leak perspective.
I don't think this is a leak at all. We *never* can reach the end of the scope
in which userDoption is allocated. We abort() if the end of PostmasterMain()
is ever reached. What is the leak here supposed to actually be?
> So I don't think it needs to be backpatched to the stable branches.
Definitely not.
> OTOH, if it helps keep Valgrind quiet for userDoption, I may be ok with
> applying it to master.
I'm doubtful it makes sense to fix it this way.
If we do it, we should actually be a bit more systematic and also free
output_config_variable.
ISTM those strdup()s should actually be pstrdup()s? I suspect changing that
would also silence valgrind.
Greetings,
Andres Freund
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul A Jungwirth | 2026-04-22 18:03:18 | Re: FOR PORTION OF does not recompute GENERATED STORED columns that depend on the range column |
| Previous Message | Bertrand Drouvot | 2026-04-22 17:32:27 | Re: Cleanup explain_memoize function after test |