pgsql: Fix bogus initialization of replication origin shared memory sta

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix bogus initialization of replication origin shared memory sta
Date: 2020-05-15 23:06:05
Message-ID: E1jZjP3-0001CU-T6@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix bogus initialization of replication origin shared memory state.

The previous coding zeroed out offsetof(ReplicationStateCtl, states)
more bytes than it was entitled to, as a consequence of starting the
zeroing from the wrong pointer (or, if you prefer, using the wrong
calculation of how much to zero).

It's unsurprising that this has not caused any reported problems,
since it can be expected that the newly-allocated block is at the end
of what we've used in shared memory, and we always make the shmem
block substantially bigger than minimally necessary. Nonetheless,
this is wrong and it could bite us someday; plus it's a dangerous
model for somebody to copy.

This dates back to the introduction of this code (commit 5aa235042),
so back-patch to all supported branches.

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ee39a4b9e475348dd3de82781a54be82e63a3186

Modified Files
--------------
src/backend/replication/logical/origin.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-05-15 23:56:08 pgsql: Drop the redundant "Lock" suffix from LWLock wait event names.
Previous Message Tom Lane 2020-05-15 22:11:20 pgsql: Rename assorted LWLock tranches.