Re: pgsql: Introduce a new mechanism for registering shared memory areas

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Introduce a new mechanism for registering shared memory areas
Date: 2026-04-06 12:38:53
Message-ID: 261dc9d4-0b87-4e7e-aded-842ed82298e5@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On 06/04/2026 14:55, Aleksander Alekseev wrote:
>> Introduce a new mechanism for registering shared memory areas
>>
>> [...]
>
> This commit introduced a memory leak which Valgrind is very much upset about.
>
> ShmemRequestStructWithOpts() allocates a copy of `options` in
> TopMemoryContext and passes it to ShmemRequestInternal(). It appends
> it to pending_shmem_requests as request->options. Later in
> ShmemInitRequested() when the list is freed `->options` leak. There
> are similar issues in ShmemAttachRequested() and
> CallShmemCallbacksAfterStartup() which free pending_shmem_requests
> without freeing `->options`.
>
> I propose to fix it as attached.

LGTM, I will push this shortly. Thanks!

- Heikki

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-04-06 13:04:15 pgsql: Fix memory leaks introduced by commit 283e823f9dcb
Previous Message Heikki Linnakangas 2026-04-06 12:31:28 Re: pgsql: Convert all remaining subsystems to use the new shmem allocation