initdb fails under bleeding-edge valgrind - Mailing list pgsql-hackers

From Tom Lane
Subject initdb fails under bleeding-edge valgrind
Date
Msg-id 161790.1608310142@sss.pgh.pa.us
Whole thread Raw
List 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



pgsql-hackers by date:

Previous
From: "Drouvot, Bertrand"
Date:
Subject: Re: Deadlock between backend and recovery may not be detected
Next
From: Bruce Momjian
Date:
Subject: Re: Proposed patch for key managment