Re: Portability issues in shm_mq

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Portability issues in shm_mq
Дата
Msg-id 25620.1394983576@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Portability issues in shm_mq  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Portability issues in shm_mq  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Fri, Mar 14, 2014 at 4:43 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> How is that leading to a crash?  Well, this machine is 32-bit, so MAXALIGN
>> is only 4.  This means it is possible for an odd-length message cum
>> message length word to not exactly divide the size of the shared memory
>> ring buffer, resulting in cases where an 8-byte message length word is
>> wrapped around the end of the buffer.

> Argh.  I think I forced the size of the buffer to be MAXALIGN'd, but
> what it really needs is to be a multiple of the size of uint64.

After sleeping on it, I think what you're proposing here is to double down
on a wrong design decision.  ISTM you should change the message length
words to be size_t (or possibly ssize_t, if you're depending on signed
arithmetic), which would let you keep using MAXALIGN as the alignment
macro.  There is absolutely no benefit, either for performance or code
readability, in forcing 32-bit machines to use 64-bit message length
words.  Indeed, by not using the same alignment macros as everywhere else
and not being able to use %zu for debug printouts, I think the only real
effect you're producing is to make the DSM/MQ stuff more and more randomly
unlike the rest of Postgres.  Please reconsider while it's still not too
late to change those APIs.
        regards, tom lane



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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: [RFC] What should we do for reliable WAL archiving?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: create type- similar char