Re: Possible uninitialized use of the variables (src/backend/access/transam/twophase.c)

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: ranier(dot)vf(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Possible uninitialized use of the variables (src/backend/access/transam/twophase.c)
Date: 2022-02-10 01:18:15
Message-ID: 20220210.101815.265604321529150472.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Wed, 9 Feb 2022 08:15:45 -0300, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote in
> Hi,
>
> Commit
> https://github.com/postgres/postgres/commit/1eb6d6527aae264b3e0b9c95aa70bb7a594ad1cf,
> modified
> data struct TwoPhaseFileHeader and added two new fields:
>
> XLogRecPtr origin_lsn; /* lsn of this record at origin node */
> TimestampTz origin_timestamp; /* time of prepare at origin node */
>
> I think thay forgot initialize these fields in the function StartPrepare
> because,
> when calling function save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
>
> I have one report about possible uninitialized usage of the variables.

Who repoerted that to you?

StartPrepare and EndPrepare are virtually a single function that
accepts some additional operations in the middle. StartPrepare leaves
the "records" incomplete then EndPrepare completes it. It is not
designed so that the fields are accessed from others before the
completion. There seems to be no critical reasons for EndPrepare to
do the pointed operations, but looking that another replorigin-related
operation is needed in the same function, it is sensible that the
author intended to consolidate all replorigin related changes in
EndPrepare.

So, my humble opinion here is, that change is not needed.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2022-02-10 01:37:30 Re: GetRelationPublicationActions. - Remove unreachable code
Previous Message Michael Paquier 2022-02-10 01:01:08 Re: Justin Pryzby <pryzby@telsasoft.com>