]> granicus.if.org Git - postgresql/commitdiff
Avoid another valgrind complaint about write() of uninitalized bytes.
authorRobert Haas <rhaas@postgresql.org>
Thu, 22 Feb 2018 14:28:12 +0000 (09:28 -0500)
committerRobert Haas <rhaas@postgresql.org>
Thu, 22 Feb 2018 14:28:12 +0000 (09:28 -0500)
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

index d6794bf3de1ee38f7fc954c21b9a9030e5bfd9f8..05dde631ddc5e657c6d9434f9733639ab24e619f 100644 (file)
@@ -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);
                }