Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkCjC-0001j9-Rc for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jul 2019 19:21:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkCjB-0007a8-Gh for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jul 2019 19:21:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkCjB-0007a1-6C for pgsql-bugs@lists.postgresql.org; Sun, 07 Jul 2019 19:21:37 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkCj4-0006Xk-QA for pgsql-bugs@lists.postgresql.org; Sun, 07 Jul 2019 19:21:36 +0000 Received: by mail-lj1-x22c.google.com with SMTP id m8so4256753lji.7 for ; Sun, 07 Jul 2019 12:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=cFMVMN0zrnYb+HFbLhe82Awl1qsbRzMjfFQHighDoLs=; b=E5mm4Ch1F1cpzAaTA4FZdydo9G+4RYFkpxoHL8Lb6ZzZlVqajEtMLuMqk9MKKdNAXe aep0AfXlPOdqnVzmu0LALIjGaAR16W/EvcOOxRpVddPKw22M85bvUDyUOha6h6l3dot6 QzuhcUAuuAVagmCn8Vp93mWBJuUG1gMXOCyR1cg//BRxg0EalCeC7H2SgyiCXZ8l4dIt N4nNMsfrECNsiXGIlCZa1/3W//D1U3ZoEzztjzfCJay1BTQZ/l0AUAFV4pvWFx3BQwq8 OhYrusZbyGyW55DuM9rdlmm7NmR0XeuOCu+CmVNA9BTkD08TU8XKtLsYOFnj6JZY3h+C ISLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=cFMVMN0zrnYb+HFbLhe82Awl1qsbRzMjfFQHighDoLs=; b=pVqi9Iq+HS+zYqVpEaWY/ZJac7+36VQHAUeTxiKfFTxQnYsgcalnLCN6GLIeRfmD/V jOtgxZv0NcdfQbHth+PY6bemBtACGQm5e4R3vlWuA3FmP9YTRFlQM3Q+XtoxTWdrvUiy JiTVPUmKghbXai4PrOy/fjdRm6vUEiB5WelzwU+xQ3ZO0VhKRA5l4U43gWxCWrryesQX uSYWzk8uDYZH5/up+NaggreudHQWFe5xydvLKPv5vpp6KHJnGePohxeCzond6m3OMRe3 hJSj1PLMW71x7jiOJOG584YHXUzVkBgCOChm/KvIipIp9qlqCL2keURbCxqrq9MbqYHk pEgw== X-Gm-Message-State: APjAAAVbmG4tPsS04J4+cjOVpofO8eKbEq+UBzOisXMrtTO7JAfTx7PH ixOseXqCgAuiy469JFRkZ6D/3vDwv+M= X-Google-Smtp-Source: APXvYqxiT8tVOVdDI8dBKFrCP2CCJVSSuPimpV4320f6ZwX0QQh9COp6opM7ttzyBUDAuRGE1T149w== X-Received: by 2002:a2e:b4c9:: with SMTP id r9mr352931ljm.196.1562527288405; Sun, 07 Jul 2019 12:21:28 -0700 (PDT) Received: from [1.0.0.7] ([178.155.4.5]) by smtp.gmail.com with ESMTPSA id 2sm3124391lji.94.2019.07.07.12.21.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jul 2019 12:21:27 -0700 (PDT) Subject: Re: BUG #15899: Valgrind detects errors on create gist index To: pgsql-bugs@lists.postgresql.org References: <15899-0d24fb273b3dd90c@postgresql.org> From: Alexander Lakhin Message-ID: <38f18230-e766-3a87-e3ad-fef6562c0c23@gmail.com> Date: Sun, 7 Jul 2019 22:21:26 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <15899-0d24fb273b3dd90c@postgresql.org> Content-Type: multipart/mixed; boundary="------------A43D0B97F0A4311518BF89BE" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------A43D0B97F0A4311518BF89BE Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit > 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 --------------A43D0B97F0A4311518BF89BE Content-Type: text/x-patch; name="gistbuildbuffers.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gistbuildbuffers.patch" 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 */ --------------A43D0B97F0A4311518BF89BE--