agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Fix valgrind failure
3+ messages / 2 participants
[nested] [flat]

* pgsql: Fix valgrind failure
@ 2026-04-07 09:15  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Álvaro Herrera @ 2026-04-07 09:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix valgrind failure

Buildfarm member skink reports that the new REPACK code is trying to
write uninitialized bytes to disk, which correspond to padding space in
the SerializedSnapshotData struct.  Silence that by initializing the
memory in SerializeSnapshot() to all zeroes.

Co-authored-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Co-authored-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/1976915.1775537087@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5bcc3fbd196ccbec55c2ce6b58d6946f06cf6213

Modified Files
--------------
src/backend/commands/repack_worker.c | 2 +-
src/backend/utils/time/snapmgr.c     | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pgsql: Fix valgrind failure
@ 2026-04-07 09:41  Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
  parent: Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Bertrand Drouvot @ 2026-04-07 09:41 UTC (permalink / raw)
  To: Álvaro Herrera <alvherre@kurilemu.de>; +Cc: pgsql-committers@lists.postgresql.org

Hi,

On Tue, Apr 07, 2026 at 09:15:34AM +0000, Álvaro Herrera wrote:
> Fix valgrind failure
> 
> Buildfarm member skink reports that the new REPACK code is trying to
> write uninitialized bytes to disk, which correspond to padding space in
> the SerializedSnapshotData struct.  Silence that by initializing the
> memory in SerializeSnapshot() to all zeroes.

-       SerializedSnapshotData serialized_snapshot;
+       SerializedSnapshotData serialized_snapshot = {0};

Should we use memset() instead? As "= {0}" is guaranteed to zero padding bytes
(for object that has automatic storage duration) as of C23 (see Andres's reply
in [0]) but we require C11 so far.

I wonder if we should introduce a new macro say "INITIALIZE_PADDING" that I
proposed in [1].

[0]: https://postgr.es/m/aoaj45foewpjtu6r5cs67yrx4en3pkurs23e4azv6tbikpw6c3%40h3pnaqaksoeg
[1]: https://postgr.es/m/ablMZvnGhX8h5GgK%40ip-10-97-1-34.eu-west-3.compute.internal

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pgsql: Fix valgrind failure
@ 2026-04-07 13:29  Álvaro Herrera <alvherre@kurilemu.de>
  parent: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Álvaro Herrera @ 2026-04-07 13:29 UTC (permalink / raw)
  To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org

Hello,

On 2026-Apr-07, Bertrand Drouvot wrote:

> -       SerializedSnapshotData serialized_snapshot;
> +       SerializedSnapshotData serialized_snapshot = {0};
> 
> Should we use memset() instead? As "= {0}" is guaranteed to zero padding bytes
> (for object that has automatic storage duration) as of C23 (see Andres's reply
> in [0]) but we require C11 so far.

Hmm ... I'll wait for skink to fail with the fix that was committed,
before making further changes.  It may well be that it works okay as it
is now.

> I wonder if we should introduce a new macro say "INITIALIZE_PADDING"
> that I proposed in [1].
> 
> [1]: https://postgr.es/m/ablMZvnGhX8h5GgK%40ip-10-97-1-34.eu-west-3.compute.internal

It's not clear to me how that would be used exactly (surely it needs to
be part of the initialization? But what if you have to use memset?), but
the idea looks rather ugly.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-04-07 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-04-07 09:15 pgsql: Fix valgrind failure Álvaro Herrera <alvherre@kurilemu.de>
2026-04-07 09:41 ` Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
2026-04-07 13:29   ` Álvaro Herrera <alvherre@kurilemu.de>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox