From 5bcc3fbd196ccbec55c2ce6b58d6946f06cf6213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= Date: Tue, 7 Apr 2026 11:13:16 +0200 Subject: [PATCH] Fix valgrind failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Álvaro Herrera Discussion: https://postgr.es/m/1976915.1775537087@sss.pgh.pa.us --- src/backend/commands/repack_worker.c | 2 +- src/backend/utils/time/snapmgr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/repack_worker.c b/src/backend/commands/repack_worker.c index 94d034970b5..d06bc1dd270 100644 --- a/src/backend/commands/repack_worker.c +++ b/src/backend/commands/repack_worker.c @@ -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); diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index 2e6197f5f35..10fe18df2e7 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -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);