Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)

From: Greg Nancarrow <gregn4422(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, David Zhang <david(dot)zhang(at)highgo(dot)ca>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)
Date: 2022-01-27 12:32:52
Message-ID: CAJcOf-d7pRy7rJcb47HExUmPCqyuuwjps5Jt1uDRbL9H31hLiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 27, 2022 at 6:32 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Fri, Oct 01, 2021 at 05:03:04PM -0300, Ranier Vilela wrote:
> > For me the assertion remains valid and usable.
>
> Well, I was looking at this thread again, and I still don't see what
> we benefit from this change. One thing that could also be done is to
> initialize "result" at {0} at the top of FreePageManagerGetInternal()
> and FreePageManagerPutInternal(), but that's in the same category as
> the other suggestions. I'll go drop the patch if there are no
> objections.

Why not, at least, just add "Assert(result.page != NULL);" after the
"Assert(!result.found);" in FreePageManagerPutInternal()?
The following code block in FreePageBtreeSearch() - which lacks those
initializations - should never be invoked in this case, and the added
Assert will make this more obvious.

if (btp == NULL)
{
result->page = NULL;
result->found = false;
return;
}

Regards,
Greg Nancarrow
Fujitsu Australia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2022-01-27 12:36:56 Re: Add connection active, idle time to pg_stat_activity
Previous Message tushar 2022-01-27 12:15:16 Re: refactoring basebackup.c