pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15899: Valgrind detects errors on create gist index
Date: Sun, 7 Jul 2019 22:21:26 +0300
Message-ID: <38f18230-e766-3a87-e3ad-fef6562c0c23@gmail.com> (raw)
In-Reply-To: <15899-0d24fb273b3dd90c@postgresql.org>
References: <15899-0d24fb273b3dd90c@postgresql.org>

> When executing under valgrind the following script:
> create table gist_point_tbl(id int4, p point);
> insert into gist_point_tbl (id, p)
> select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g;
> create index gist_pointidx2 on gist_point_tbl using gist(p) with (buffering
> = on, fillfactor=50);
>
> I get several valgrind errors:
> 2019-07-07 22:01:02.957 MSK|law|regression|5d22416b.5a20|LOG:  statement:
> create index gist_pointidx2 on gist_point_tbl using gist(p) with (buffering
> = on, fillfactor=50);
> ==00:00:00:12.567 23072== Conditional jump or move depends on uninitialised
> value(s)
> ==00:00:00:12.567 23072==    at 0x1F977B: gistAddLoadedBuffer
> (gistbuildbuffers.c:205)
> ==00:00:00:12.567 23072==    by 0x1F9E05: gistPushItupToNodeBuffer
> (gistbuildbuffers.c:356)
> ==00:00:00:12.567 23072==    by 0x1F89F2: gistProcessItup
> (gistbuild.c:645)
> ==00:00:00:12.567 23072==    by 0x1F8AE2: gistBufferingBuildInsert
> (gistbuild.c:536)
>
> ...
> ==00:00:00:12.662 23072== Syscall param pwrite64(buf) points to
> uninitialised byte(s)
> ==00:00:00:12.662 23072==    at 0x5055014: pwrite (pwrite64.c:29)
> ==00:00:00:12.662 23072==    by 0x4F1CC0: FileWrite (fd.c:1963)
> ==00:00:00:12.662 23072==    by 0x4F3C83: BufFileDumpBuffer
> (buffile.c:487)
> ==00:00:00:12.662 23072==    by 0x4F4275: BufFileWrite (buffile.c:589)
> ==00:00:00:12.662 23072==    by 0x1F9841: WriteTempFileBlock
> (gistbuildbuffers.c:770)
> ==00:00:00:12.662 23072==    by 0x1F9E2E: gistPushItupToNodeBuffer
> (gistbuildbuffers.c:375)
> ==00:00:00:12.662 23072==    by 0x1F89F2: gistProcessItup
> (gistbuild.c:645)
The attached patch eliminates these errors (but maybe
MemoryContextAllocZero is too superficial).

Best regards,
Alexander

Attachments:

gistbuildbuffers.patch (text/x-patch, 914B) download diff --git a/src/backend/access/gist/gistbuildbuffers.c b/src/backend/access/gist/gistbuildbuffers.c index d71354140e..5d26350690 100644 --- a/src/backend/access/gist/gistbuildbuffers.c +++ b/src/backend/access/gist/gistbuildbuffers.c @@ -139,6 +139,7 @@ gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, nodeBuffer->pageBuffer = NULL; nodeBuffer->queuedForEmptying = false; nodeBuffer->level = level; + nodeBuffer->isTemp = false; /* * Add this buffer to the list of buffers on this level. Enlarge @@ -186,8 +187,8 @@ gistAllocateNewPageBuffer(GISTBuildBuffers *gfbb) { GISTNodeBufferPage *pageBuffer; - pageBuffer = (GISTNodeBufferPage *) MemoryContextAlloc(gfbb->context, - BLCKSZ); + pageBuffer = (GISTNodeBufferPage *) MemoryContextAllocZero(gfbb->context, + BLCKSZ); pageBuffer->prev = InvalidBlockNumber; /* Set page free space */

view thread (6+ messages)  latest in thread

Message-ID: <38f18230-e766-3a87-e3ad-fef6562c0c23@gmail.com>
Permalink:  ../38f18230-e766-3a87-e3ad-fef6562c0c23@gmail.com/
Also on:    postgresql.org/message-id/38f18230-e766-3a87-e3ad-fef6562c0c23@gmail.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #15899: Valgrind detects errors on create gist index
  In-Reply-To: <38f18230-e766-3a87-e3ad-fef6562c0c23@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox