initdb fails under bleeding-edge valgrind

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: initdb fails under bleeding-edge valgrind
Date: 2020-12-18 16:49:02
Message-ID: 161790.1608310142@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2020-12-18 17:02:50 Re: Proposed patch for key managment
Previous Message Drouvot, Bertrand 2020-12-18 16:43:12 Re: Deadlock between backend and recovery may not be detected