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
Ответ на
Список
Дерево обсуждения
[BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border bret.shao@outlook.com
Re: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border Michael Paquier <michael.paquier@gmail.com>
Re: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory accesscross-border Andres Freund <andres@anarazel.de>
Re: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border Michael Paquier <michael.paquier@gmail.com>
[BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border shao bret <bret.shao@outlook.com>
Re: [BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border Andres Freund <andres@anarazel.de>
[BUGS] 答复: [BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border shao bret <bret.shao@outlook.com>
[BUGS] Re: 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border Michael Paquier <michael.paquier@gmail.com>
[BUGS] 答复: 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border shao bret <bret.shao@outlook.com>
On Wed, Apr 12, 2017 at 12:20 AM, Andres Freund 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 по дате отправления
От: shao bret
Дата: