Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kqIwK-0004ks-8x for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Dec 2020 16:49:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kqIwJ-000348-2d for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Dec 2020 16:49:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kqIwI-000341-Cy for pgsql-hackers@lists.postgresql.org; Fri, 18 Dec 2020 16:49:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kqIwC-0008VA-3R for pgsql-hackers@lists.postgresql.org; Fri, 18 Dec 2020 16:49:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0BIGn2hP161791 for ; Fri, 18 Dec 2020 11:49:02 -0500 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: initdb fails under bleeding-edge valgrind MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <161789.1608310142.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 18 Dec 2020 11:49:02 -0500 Message-ID: <161790.1608310142@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk With valgrind 3.16.1, we fail to get through initdb: =3D=3D00:00:00:41.608 11346=3D=3D Source and destination overlap in memcpy= (0xc190a8, 0xc190a8, 512) =3D=3D00:00:00:41.609 11346=3D=3D at 0x486C674: __GI_memcpy (vg_replace= _strmem.c:1035) =3D=3D00:00:00:41.609 11346=3D=3D by 0x9017DB: write_relmap_file (relma= pper.c:932) =3D=3D00:00:00:41.609 11346=3D=3D by 0x90243B: RelationMapFinishBootstr= ap (relmapper.c:571) =3D=3D00:00:00:41.609 11346=3D=3D by 0x551083: BootstrapModeMain (boots= trap.c:530) =3D=3D00:00:00:41.609 11346=3D=3D by 0x551083: AuxiliaryProcessMain (bo= otstrap.c:436) =3D=3D00:00:00:41.609 11346=3D=3D by 0x483E8F: main (main.c:201) =3D=3D00:00:00:41.609 11346=3D=3D = =3D=3D00:00:00:41.615 11346=3D=3D Source and destination overlap in memcpy= (0xc192a8, 0xc192a8, 512) =3D=3D00:00:00:41.615 11346=3D=3D at 0x486C674: __GI_memcpy (vg_replace= _strmem.c:1035) =3D=3D00:00:00:41.615 11346=3D=3D by 0x9017DB: write_relmap_file (relma= pper.c:932) =3D=3D00:00:00:41.615 11346=3D=3D by 0x551083: BootstrapModeMain (boots= trap.c:530) =3D=3D00:00:00:41.615 11346=3D=3D by 0x551083: AuxiliaryProcessMain (bo= otstrap.c:436) =3D=3D00:00:00:41.615 11346=3D=3D by 0x483E8F: main (main.c:201) =3D=3D00:00:00:41.615 11346=3D=3D = 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 !=3D 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