Thread
Commits
-
Avoid memcpy() with same source and destination during relmapper init.
- ba04cedf1d26 12.6 landed
- b70cab8a2c83 10.16 landed
- 94aaa79afe65 9.5.25 landed
- 722eb325b951 13.2 landed
- 53d4f5fef046 14.0 landed
- 48786740094c 9.6.21 landed
- 21b2ee6ee376 11.11 landed
-
initdb fails under bleeding-edge valgrind
Tom Lane <tgl@sss.pgh.pa.us> — 2020-12-18T16:49:02Z
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