From 9561f6e97790613d2e02f1af44913402c8858dd6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 21 May 2016 17:37:16 -0400 Subject: [PATCH] Fix missing initialization of buffer_std field in _bt_newroot(). This would only have any effect if the old root page needed to have a full-page image made (ie, this was the first mod to it since a checkpoint), *and* if the byte left uninitialized chanced to contain zero. In that case the WAL code would fail to remove the "hole" from the full-page image, which would bloat the WAL log a bit but not have any effect worse than that. Found by buildfarm member skink, whose valgrind run noticed the use of an uninitialized value. Apparently timing in the regression tests is such that the triggering condition is rare, or valgrind testing would have seen this before. Oversight in commit 40dae7ec537c5619fc93ad602c62f37be786d161. This bug affects only the 9.4 branch, since in later branches refactoring of the WAL-log-creation APIs fixed it. Report: <20160521203101.jp5yxquhhkabvo56@alap3.anarazel.de> --- src/backend/access/nbtree/nbtinsert.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 56313dc6c8d..91c8ebf7eb8 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -2118,6 +2118,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) rdata[2].data = NULL; rdata[2].len = 0; rdata[2].buffer = lbuf; + rdata[2].buffer_std = true; rdata[2].next = NULL; recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_NEWROOT, rdata); -- 2.39.5