From b19890d49d122257ddcdb7ab2c5038f5075906c1 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 1 Dec 2023 22:30:08 +0200 Subject: [PATCH] Silence Valgrind complaint with EXEC_BACKEND The padding bytes written to the backend params file were uninitialized. That's harmless because we don't access the padding bytes when we read the file back in, but Valgrind doesn't know that. In any case, clear the padding bytes to make Valgrind happy. Reported-by: Alexander Lakhin Discussion: https://www.postgresql.org/message-id/014768ed-8b39-c44f-b07c-098c87b1644c@gmail.com --- src/backend/postmaster/postmaster.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 7a5cd06c5c..ccc12f91a1 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -4490,6 +4490,14 @@ internal_forkexec(int argc, char *argv[], Port *port) BackendParameters param; FILE *fp; + /* + * Make sure padding bytes are initialized, to prevent Valgrind from + * complaining about writing uninitialized bytes to the file. This isn't + * performance critical, and the win32 implementation initializes the + * padding bytes to zeros, so do it even when not using Valgrind. + */ + memset(¶m, 0, sizeof(BackendParameters)); + if (!save_backend_variables(¶m, port)) return -1; /* log made by save_backend_variables */ -- 2.39.5