pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Subject: initdb fails under bleeding-edge valgrind
Date: Fri, 18 Dec 2020 11:49:02 -0500
Message-ID: <161790.1608310142@sss.pgh.pa.us> (raw)

With valgrind 3.16.1, we fail to get through initdb:

==00:00:00:41.608 11346== Source and destination overlap in memcpy(0xc190a8, 0xc190a8, 512)
==00:00:00:41.609 11346==    at 0x486C674: __GI_memcpy (vg_replace_strmem.c:1035)
==00:00:00:41.609 11346==    by 0x9017DB: write_relmap_file (relmapper.c:932)
==00:00:00:41.609 11346==    by 0x90243B: RelationMapFinishBootstrap (relmapper.c:571)
==00:00:00:41.609 11346==    by 0x551083: BootstrapModeMain (bootstrap.c:530)
==00:00:00:41.609 11346==    by 0x551083: AuxiliaryProcessMain (bootstrap.c:436)
==00:00:00:41.609 11346==    by 0x483E8F: main (main.c:201)
==00:00:00:41.609 11346== 
==00:00:00:41.615 11346== Source and destination overlap in memcpy(0xc192a8, 0xc192a8, 512)
==00:00:00:41.615 11346==    at 0x486C674: __GI_memcpy (vg_replace_strmem.c:1035)
==00:00:00:41.615 11346==    by 0x9017DB: write_relmap_file (relmapper.c:932)
==00:00:00:41.615 11346==    by 0x551083: BootstrapModeMain (bootstrap.c:530)
==00:00:00:41.615 11346==    by 0x551083: AuxiliaryProcessMain (bootstrap.c:436)
==00:00:00:41.615 11346==    by 0x483E8F: main (main.c:201)
==00:00:00:41.615 11346== 

I'm a bit surprised that we've not seen other complaints from picky
memcpy implementations, because this code path definitely is passing
the same source and destination pointers.

Evidently we need something like this in write_relmap_file:

	/* Success, update permanent copy */
-	memcpy(realmap, newmap, sizeof(RelMapFile));
+	if (realmap != newmap)
+		memcpy(realmap, newmap, sizeof(RelMapFile));

Or possibly it'd be cleaner to have RelationMapFinishBootstrap
supply a local RelMapFile variable to construct the mappings in.

			regards, tom lane





Message-ID: <161790.1608310142@sss.pgh.pa.us>
Permalink:  ../161790.1608310142@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/161790.1608310142@sss.pgh.pa.us

 · 

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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: initdb fails under bleeding-edge valgrind
  In-Reply-To: <161790.1608310142@sss.pgh.pa.us>
  References: <161790.1608310142@sss.pgh.pa.us>

* 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