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

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Greg Nancarrow <gregn4422(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, 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-03-14 19:30:37
Message-ID: CAH2-WzmK6pgrFcfkxV-xOE8R887_c-qk433FNcWL3beC1RczmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 14, 2022 at 12:15 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> If surgery does happen in the future, I would argue that this
> change could easily *mask* bugs, because if somebody tries to apply
> valgrind to this code the useless initializations will just cover up
> what valgrind would otherwise detect as an access to uninitialized
> memory.

I agree. I have found it useful to VALGRIND_MAKE_MEM_DEFINED() a
buffer that would otherwise be considered initialized by Valgrind --
sometimes it's useful to make Valgrind understand that an area of
memory is garbage for all practical purposes. In other words,
sometimes it's useful to go out of your way to work around the problem
of meaningless initialization masking bugs (bugs that could otherwise
be detected by Valgrind).

Of course it's also possible that initializing memory to some
nominally safe value (e.g. using palloc0() rather than palloc()) makes
sense as a defensive measure. It depends on the specific code, of
course.

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-03-14 19:38:23 Re: generic plans and "initial" pruning
Previous Message Robert Haas 2022-03-14 19:15:18 Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)