pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid using a fake relcache entry to own an SmgrRelation.
Date: Fri, 12 Aug 2022 12:56:05 +0000
Message-ID: <E1oMUCq-000QeC-9t@gemulon.postgresql.org> (raw)

Avoid using a fake relcache entry to own an SmgrRelation.

If an error occurs before we close the fake relcache entry, the the
fake relcache entry will be destroyed by the SmgrRelation will
survive until end of transaction. Its smgr_owner pointer ends up
pointing to already-freed memory.

The original reason for using a fake relcache entry here was to try
to avoid reusing an SMgrRelation across a relevant invalidation. To
avoid that problem, just call smgropen() again each time we need a
reference to it. Hopefully someday we will come up with a more
elegant approach, but accessing uninitialized memory is bad so let's
do this for now.

Dilip Kumar, reviewed by Andres Freund and Tom Lane. Report by
Justin Pryzby.

Discussion: http://postgr.es/m/20220802175043.GA13682@telsasoft.com
Discussion: http://postgr.es/m/CAFiTN-vSFeE6_W9z698XNtFROOA_nSqUXWqLcG0emob_kJ+dEQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/76733b399c490885564a560718de23d98bb5e66d

Modified Files
--------------
src/backend/commands/dbcommands.c   | 15 +++--------
src/backend/storage/buffer/bufmgr.c | 51 +++++++++++++++++--------------------
2 files changed, 28 insertions(+), 38 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1oMUCq-000QeC-9t@gemulon.postgresql.org>
Permalink:  ../E1oMUCq-000QeC-9t@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oMUCq-000QeC-9t@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: rhaas@postgresql.org
  Subject: Re: pgsql: Avoid using a fake relcache entry to own an SmgrRelation.
  In-Reply-To: <E1oMUCq-000QeC-9t@gemulon.postgresql.org>
  References: <E1oMUCq-000QeC-9t@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox