From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | bret(dot)shao(at)outlook(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #14615: ReplicationOriginShmemInit Memory access cross-border |
Date: | 2017-04-11 15:20:49 |
Message-ID: | 20170411152049.jus5fmjtqd4g2gdi@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 2017-04-10 15:38:56 +0900, Michael Paquier wrote:
> diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
> index 5eaf863e02..0aa468789c 100644
> --- a/src/backend/replication/logical/origin.c
> +++ b/src/backend/replication/logical/origin.c
> @@ -473,7 +473,8 @@ ReplicationOriginShmemInit(void)
>
> replication_states_ctl->tranche_id = LWTRANCHE_REPLICATION_ORIGIN;
>
> - MemSet(replication_states, 0, ReplicationOriginShmemSize());
> + MemSet(replication_states, 0,
> + mul_size(max_replication_slots, sizeof(ReplicationState)));
What's the benefit of using mul_size here? That's usually only
beneficial in the original size computation - during use/initialization
an actual error should be impossible.
To me the right fix seems to be to just do:
- replication_states_ctl->tranche_id = LWTRANCHE_REPLICATION_ORIGIN;
-
- MemSet(replication_states, 0, ReplicationOriginShmemSize());
+ MemSet(replication_states_ctl, 0, ReplicationOriginShmemSize());
+
+ replication_states_ctl->tranche_id = LWTRANCHE_REPLICATION_ORIGIN;
No?
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2017-04-11 15:22:14 | Re: 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border |
Previous Message | constantinos.eleftheriou | 2017-04-11 10:08:34 | BUG #14620: pgdg93 repo libevent conflict |