Re: pgsql: Introduce a new mechanism for registering shared memory areas - Mailing list pgsql-committers

From Aleksander Alekseev
Subject Re: pgsql: Introduce a new mechanism for registering shared memory areas
Date
Msg-id CAJ7c6TN9tp8MTc0WXM0zfSWqjfBqU8gpe+o5KqHB1-cQ7409Kw@mail.gmail.com
Whole thread Raw
In response to pgsql: Introduce a new mechanism for registering shared memory areas  (Heikki Linnakangas <heikki.linnakangas@iki.fi>)
Responses Re: pgsql: Introduce a new mechanism for registering shared memory areas
List 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

pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pgsql: Convert all remaining subsystems to use the new shmem allocation
Next
From: Robert Haas
Date:
Subject: pgsql: Add pg_stash_advice contrib module.