diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c index da3d9e828c..9ba11a73cf 100644 --- a/src/backend/utils/cache/relmapper.c +++ b/src/backend/utils/cache/relmapper.c @@ -847,8 +847,15 @@ write_relmap_file(bool shared, RelMapFile *newmap, } } - /* Success, update permanent copy */ - memcpy(realmap, newmap, sizeof(RelMapFile)); + /* + * Success, update permanent copy. During bootstrap, we might be working + * on the permanent copy itself, in which case skip the memcpy() to avoid + * invoking nominally-undefined behavior. + */ + if (realmap != newmap) + memcpy(realmap, newmap, sizeof(RelMapFile)); + else + Assert(!send_sinval); /* must be bootstrapping */ /* Critical section done */ if (write_wal)