Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding

Lukas Fittl <lukas@fittl.com>

From: Lukas Fittl <lukas@fittl.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Daniel Gustafsson <daniel@yesql.se>, Gaurav Singh <gaurav.singh@yugabyte.com>, pgsql-bugs@lists.postgresql.org
Date: 2026-03-27T15:25:47Z
Lists: pgsql-bugs
On Fri, Mar 27, 2026 at 4:13 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>
> On 27/03/2026 11:05, Daniel Gustafsson wrote:
> >> On 27 Mar 2026, at 09:59, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> >
> >> Hmm, perhaps. But there's a simpler, less invasive fix. When that code was written, we didn't have MCXT_ALLOC_HUGE nor MCXT_ALLOC_NO_OOM. Now that we do, we can just use palloc_extended(MCXT_ALLOC_HUGE | MCXT_ALLOC_NO_OOM) instead of raw malloc(). Per attached.
> >
> > LGTM.
>
> Committed, thanks!

Thanks for the quick fix!

TIL about MCXT_ALLOC_NO_OOM, that's useful to know about.

Thanks,
Lukas

-- 
Lukas Fittl



Commits

  1. Avoid memory leak on error while parsing pg_stat_statements dump file