pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Andres Freund <andres@anarazel.de>
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15943: Valgrind-detected error in SlruPhysicalWritePage
Date: Tue, 20 Aug 2019 10:00:01 +0300
Message-ID: <7b8cbcf5-58a4-c119-b25a-e82358b44f9e@gmail.com> (raw)
In-Reply-To: <8c31c946-f2e8-3b07-3191-9f5698e3dd14@gmail.com>
References: <15943-c7232c75bb276d6c@postgresql.org>
	<902AFCEA-F078-4D47-AF53-1D2FD3022657@anarazel.de>
	<8c31c946-f2e8-3b07-3191-9f5698e3dd14@gmail.com>

Hello hackers,
> 08.08.2019 13:33, Andres Freund wrote:
>> On August 8, 2019 12:44:43 AM EDT, PG Bug reporting form <noreply@postgresql.org> wrote:
>>> The following bug has been logged on the website:
>>>
>>> Bug reference:      15943
>>> Logged by:          Alexander Lakhin
>>> Email address:      exclusion@gmail.com
>>> PostgreSQL version: 12beta2
>>> Operating system:   Ubuntu 18.04
>>> Description:        
>>>
>>> When running under valgrind (sitting on the master branch):
>>> printf "SELECT pg_notify('notify_async1',NULL); %.0s" `seq 2048` | psql
>>>
>> That seems likely to be padding. Probably easier to see if you enable read-var-info and track-origins.
> Indeed, "memset(&qe, 0, sizeof(qe));" added in the beginning of
> asyncQueueAddEntries fixes the issue.
> More interestingly, "memset(qe.data, 0, sizeof(qe.data));" in the same
> place fixes it too (the patch is attached).
> So it seems, the padding in AsyncQueueEntry has an alibi.
Andres, you're right. The padding is found guilty (inside the qe.data
itself).
Please look at the patch addressing the cause of the problem (inspired
by btree_bit.c).
But if a valgrind suppression is preferred, look at the alternate patch.

Best regards,
Alexander

Attachments: download all (2 files, .tar.gz)

fix-aqe-padding.patch (text/x-patch, 1.1K) download diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 6cb2d445f0..a9d5362dc5 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -1321,19 +1321,23 @@ asyncQueueNotificationToEntry(Notification *n, AsyncQueueEntry *qe) { size_t channellen = n->channel_len; size_t payloadlen = n->payload_len; + int rawLength; int entryLength; Assert(channellen < NAMEDATALEN); Assert(payloadlen < NOTIFY_PAYLOAD_MAX_LENGTH); /* The terminators are already included in AsyncQueueEntryEmptySize */ - entryLength = AsyncQueueEntryEmptySize + payloadlen + channellen; - entryLength = QUEUEALIGN(entryLength); + rawLength = AsyncQueueEntryEmptySize + payloadlen + channellen; + entryLength = QUEUEALIGN(rawLength); qe->length = entryLength; qe->dboid = MyDatabaseId; qe->xid = GetCurrentTransactionId(); qe->srcPid = MyProcPid; memcpy(qe->data, n->data, channellen + payloadlen + 2); + /* initialize the padding bytes to zero */ + for (int i = 0; i < entryLength - rawLength; i++) + qe->data[channellen + payloadlen + 2 + i] = 0; } /*
valgrind_slru_write.patch (text/x-patch, 357B) download diff --git a/src/tools/valgrind.supp b/src/tools/valgrind.supp index ec47a228ae..72ef2a9fb1 100644 --- a/src/tools/valgrind.supp +++ b/src/tools/valgrind.supp @@ -112,6 +112,14 @@ fun:BootStrapXLOG } +{ + padding_slru_page_write + Memcheck:Param + write(buf) + ... + fun:SlruPhysicalWritePage +} + { bootstrap_write_relmap_overlap Memcheck:Overlap

view thread (8+ messages)

Message-ID: <7b8cbcf5-58a4-c119-b25a-e82358b44f9e@gmail.com>
Permalink:  ../7b8cbcf5-58a4-c119-b25a-e82358b44f9e@gmail.com/
Also on:    postgresql.org/message-id/7b8cbcf5-58a4-c119-b25a-e82358b44f9e@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: exclusion@gmail.com, andres@anarazel.de
  Subject: Re: BUG #15943: Valgrind-detected error in SlruPhysicalWritePage
  In-Reply-To: <7b8cbcf5-58a4-c119-b25a-e82358b44f9e@gmail.com>
  References: <15943-c7232c75bb276d6c@postgresql.org> <902AFCEA-F078-4D47-AF53-1D2FD3022657@anarazel.de> <8c31c946-f2e8-3b07-3191-9f5698e3dd14@gmail.com> <7b8cbcf5-58a4-c119-b25a-e82358b44f9e@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