Re: Accessing an invalid pointer in BufferManagerRelation structure

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Daniil Davydov <3danissimo(at)gmail(dot)com>
Cc: Stepan Neretin <slpmcf(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Accessing an invalid pointer in BufferManagerRelation structure
Date: 2025-10-19 11:32:13
Message-ID: 202510191108.vl5bgq4j5usd@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-Apr-14, Daniil Davydov wrote:

> On Wed, Mar 26, 2025 at 2:14 PM Stepan Neretin <slpmcf(at)gmail(dot)com> wrote:

> > The first thing we both noticed is that the macro calls a function
> > that won't be available without an additional header. This seems a
> > bit inconvenient.

I think this is a fact of life. We don't have an automated check for
such patterns anymore, so the users of the macro will have to include
the other file. In any case I would rather they include utils/rel.h
themselves, than forcing rel.h into every single file that includes
bufmgr.h.

> Well, I rebased the patch onto the latest `master`
> (b51f86e49a7f119004c0ce5d0be89cdf98309141) and noticed that we don't
> need to include `rel.h` in `localbuf.c` directly anymore, because
> `#include lmgr.h` was added in memutils.h
> I guess it solves this issue. Please, see v3 patch.

Not anymore.

I edited your comments a bit. What do you think of this version?

I don't think this is backpatchable material, mainly because you said
you don't see any situations in which relcache invalidations would
occur in the middle of this. Can you can cause a problem to occur by
adding an untimely invalidation somewhere without this patch, which is
fixed by this patch?

BTW how does this interact with SMgrRelation pinning?

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Industry suffers from the managerial dogma that for the sake of stability
and continuity, the company should be independent of the competence of
individual employees." (E. Dijkstra)

Attachment Content-Type Size
v4-0001-Make-smgr-access-in-BufferManagerRelation-safe-in.patch text/x-diff 10.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rintaro Ikeda 2025-10-19 13:12:37 Re: Suggestion to add --continue-client-on-abort option to pgbench
Previous Message Álvaro Herrera 2025-10-19 10:43:31 Re: FSM doesn't recover after zeroing damaged page.