From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: anisimow.d@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17462: Invalid memory access in heapam_tuple_lock
Date: Mon, 11 Apr 2022 12:00:42 -0700
Message-ID: <20220411190042.o5ebdhc5qsejleff@alap3.anarazel.de> (raw)
In-Reply-To: <352840.1649699498@sss.pgh.pa.us>
References: <17462-9c98a0f00df9bd36@postgresql.org>
<286748.1649692519@sss.pgh.pa.us>
<288544.1649693991@sss.pgh.pa.us>
<20220411173417.ocwjn5xrkqqjiysl@alap3.anarazel.de>
<352840.1649699498@sss.pgh.pa.us>
Hi,
On 2022-04-11 13:51:38 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > One way to address it in a way not requiring an API break would be to pass
> > SnapshotAny to heap_fetch and then do an explicit visibility check "ourselves"
> > in heapam_lock_tuple().
>
> I'm not really interested in fixing this without an API break (going
> forward anyway), because as it stands heap_fetch is just an invitation
> to make this same mistake again.
My suggestion was about the back branch situation... But it seems viable going
forward as well, if we we reset tuple->t_data in the !valid case. As you say:
> It should never return a tuple pointer if we don't keep the pin on the
> associated buffer.
Agreed. If tuple->t_data were reset in the !valid case, not just the
!ItemIdIsNormal() case, bug would have been noticed immediately (isolation
tests do fail, I checked).
Another approach is to extend the SatisfiesDirty approach and store the tid of
the next tuple version in addition the xmin/xmax we already store. And have
heap_fetch() always set t_data to NULL if the snapshot check fails.
Greetings,
Andres Freund
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: andres@anarazel.de, tgl@sss.pgh.pa.us, anisimow.d@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17462: Invalid memory access in heapam_tuple_lock
In-Reply-To: <20220411190042.o5ebdhc5qsejleff@alap3.anarazel.de>
* 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