Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c) - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)
Date
Msg-id 20210818.172958.24378508451846000.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)  (Greg Nancarrow <gregn4422@gmail.com>)
Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)  (David Zhang <david.zhang@highgo.ca>)
List pgsql-hackers
At Tue, 17 Aug 2021 17:04:44 +0900, Michael Paquier <michael@paquier.xyz> wrote in
> On Fri, Jul 02, 2021 at 06:22:56PM -0300, Ranier Vilela wrote:
> > Em qui., 1 de jul. de 2021 às 17:20, Mahendra Singh Thalor <
> > mahi6run@gmail.com> escreveu:
> >> Please can we try to hit this rare condition by any test case. If you have
> >> any test cases, please share.
>
> Yeah, this needs to be proved.  Are you sure that this change is
> actually right?  The bottom of FreePageManagerPutInternal() has
> assumptions that a page may not be found during a btree search, with
> an index value used.

By a quick look, FreePageBtreeSearch is called only from
FreePageManagerPutInternal at three points. The first one assumes that
result.found == true, at the rest points are passed only when
fpm->btree_depth > 0, i.e, fpm->btree_root is non-NULL.

In short FreePageBtreeSeach is never called when fpm->btree_root is
NULL.  I don't think we need to fill-in other members since the
contract of the function looks fine.

It might be simpler to turn 'if (btp == NULL)' to an assertion.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Denis Hirn
Date:
Subject: Re: [PATCH] Allow multiple recursive self-references
Next
From: Masahiko Sawada
Date:
Subject: Re: Skipping logical replication transactions on subscriber side