]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix valgrind failure
authorÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 7 Apr 2026 09:13:16 +0000 (11:13 +0200)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 7 Apr 2026 09:13:50 +0000 (11:13 +0200)
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

src/backend/commands/repack_worker.c
src/backend/utils/time/snapmgr.c

index 94d034970b5224d3fe1b595ac16e3e62ee71b917..d06bc1dd270cbaf9f4ab2ccf638e17894f2ce73c 100644 (file)
@@ -342,8 +342,8 @@ export_initial_snapshot(Snapshot snapshot, DecodingWorkerShared *shared)
        /* To make restoration easier, write the snapshot size first. */
        BufFileWrite(file, &snap_size, sizeof(snap_size));
        BufFileWrite(file, snap_space, snap_size);
-       pfree(snap_space);
        BufFileClose(file);
+       pfree(snap_space);
 
        /* Increase the counter to tell the backend that the file is available. */
        SpinLockAcquire(&shared->mutex);
index 2e6197f5f35ca4d57769ad5d082b76fafac02d55..10fe18df2e7a468b20536457be8d3ef4fd8f5d2d 100644 (file)
@@ -1735,7 +1735,7 @@ EstimateSnapshotSpace(Snapshot snapshot)
 void
 SerializeSnapshot(Snapshot snapshot, char *start_address)
 {
-       SerializedSnapshotData serialized_snapshot;
+       SerializedSnapshotData serialized_snapshot = {0};
 
        Assert(snapshot->subxcnt >= 0);