pgsql: Avoid using a fake relcache entry to own an SmgrRelation.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid using a fake relcache entry to own an SmgrRelation.
Date: 2022-08-12 12:56:05
Message-ID: E1oMUCq-000QeC-9t@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2022-08-12 13:07:13 pgsql: doc: clarify DROP EXTENSION dependent members text
Previous Message Alvaro Herrera 2022-08-12 11:17:33 pgsql: MERGE docs adjustments