Re: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border
Дата
Msg-id CAB7nPqT_GXtG6j3YVZtZmLLXJAfv_Fvr5_Hyb2bnYr8ALORVPw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory accesscross-border  (Andres Freund <andres@anarazel.de>)
Список pgsql-bugs
On Wed, Apr 12, 2017 at 12:20 AM, Andres Freund <andres@anarazel.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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Devrim Gündüz
Дата:
Сообщение: Re: [BUGS] BUG #14620: pgdg93 repo libevent conflict
Следующее
От: shao bret
Дата:
Сообщение: [BUGS] 答复: [BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border