From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
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 23:49:16 |
Message-ID: | CAB7nPqT_GXtG6j3YVZtZmLLXJAfv_Fvr5_Hyb2bnYr8ALORVPw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Wed, Apr 12, 2017 at 12:20 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> 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.
Clarity in initializing only the replication states.
> 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?
That's what Bret is proposing. I am fine either way.
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | shao bret | 2017-04-12 02:17:11 | 答复: [BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border |
Previous Message | Devrim Gündüz | 2017-04-11 16:15:09 | Re: BUG #14620: pgdg93 repo libevent conflict |