Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fafa41

Browse files
committed
Avoid valgrind complaint about write() of uninitalized bytes.
LogicalTapeFreeze() may write out its first block when it is dirty butnot full, and then immediately read the first block back in from itsBufFile as a BLCKSZ-width block. This can only occur in rare caseswhere very few tuples were written out, which is currently onlypossible with parallel external tuplesorts. To avoid valgrindcomplaints, tell it to treat the tail of logtape.c's buffer asdefined.Commit9da0cc3 exposed this problembut did not create it. LogicalTapeFreeze() has always tended to writeout some amount of garbage bytes, but previously never wrote less thanone block of data in total, so the problem was masked.Per buildfarm members lousyjack and skink.Peter Geoghegan, based on a suggestion from Tom Lane and me. Somecomment revisions by me.
1 parent3785f7e commit9fafa41

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/backend/utils/sort/logtape.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include"storage/buffile.h"
8787
#include"utils/builtins.h"
8888
#include"utils/logtape.h"
89+
#include"utils/memdebug.h"
8990
#include"utils/memutils.h"
9091

9192
/*
@@ -874,6 +875,17 @@ LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum, TapeShare *share)
874875
*/
875876
if (lt->dirty)
876877
{
878+
/*
879+
* As long as we've filled the buffer at least once, its contents are
880+
* entirely defined from valgrind's point of view, even though
881+
* contents beyond the current end point may be stale. But it's
882+
* possible - at least in the case of a parallel sort - to sort such
883+
* small amount of data that we do not fill the buffer even once. Tell
884+
* valgrind that its contents are defined, so it doesn't bleat.
885+
*/
886+
VALGRIND_MAKE_MEM_DEFINED(lt->buffer+lt->nbytes,
887+
lt->buffer_size-lt->nbytes);
888+
877889
TapeBlockSetNBytes(lt->buffer,lt->nbytes);
878890
ltsWriteBlock(lts,lt->curBlockNumber, (void*)lt->buffer);
879891
lt->writing= false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp