From de6428afe13bb6eb1c99a70aada1a105966bc27e Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 22 Feb 2018 09:28:12 -0500 Subject: [PATCH] Avoid another valgrind complaint about write() of uninitalized bytes. Peter Geoghegan, per buildfarm member skink and Andres Freund Discussion: http://postgr.es/m/20180221053426.gp72lw67yfpzkw7a@alap3.anarazel.de --- src/backend/utils/sort/logtape.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c index d6794bf3de..05dde631dd 100644 --- a/src/backend/utils/sort/logtape.c +++ b/src/backend/utils/sort/logtape.c @@ -739,6 +739,18 @@ LogicalTapeRewindForRead(LogicalTapeSet *lts, int tapenum, size_t buffer_size) */ if (lt->dirty) { + /* + * As long as we've filled the buffer at least once, its contents + * are entirely defined from valgrind's point of view, even though + * contents beyond the current end point may be stale. But it's + * possible - at least in the case of a parallel sort - to sort + * such small amount of data that we do not fill the buffer even + * once. Tell valgrind that its contents are defined, so it + * doesn't bleat. + */ + VALGRIND_MAKE_MEM_DEFINED(lt->buffer + lt->nbytes, + lt->buffer_size - lt->nbytes); + TapeBlockSetNBytes(lt->buffer, lt->nbytes); ltsWriteBlock(lts, lt->curBlockNumber, (void *) lt->buffer); } -- 2.40.0