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

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Subject: Re: pgsql: Introduce a new mechanism for registering shared memory areas
Date: 2026-04-06 11:55:21
Message-ID: CAJ7c6TN9tp8MTc0WXM0zfSWqjfBqU8gpe+o5KqHB1-cQ7409Kw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Hi Heikki,

> 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.

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
v1-0001-Fix-memory-leaks-introduced-by-commit-283e823f9dc.patch text/x-patch 1.5 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2026-04-06 11:57:03 pgsql: Add pg_stash_advice contrib module.
Previous Message Michael Paquier 2026-04-06 05:41:04 Re: pgsql: Convert all remaining subsystems to use the new shmem allocation