Re: [HACKERS] Small fix: avoid passing null pointers to memcpy()

Поиск
Список
Период
Сортировка
От didier
Тема Re: [HACKERS] Small fix: avoid passing null pointers to memcpy()
Дата
Msg-id CAJRYxu+YdYjTeT6=EG3Gi7RwtyL_XS5b7FaJNwtZCGHvRL1-gA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Small fix: avoid passing null pointers to memcpy()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On Fri, May 24, 2019 at 6:35 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:


> These seem to be down to use of AnyArrayType:
>
> typedef union AnyArrayType
> {
>         ArrayType       flt;
>         ExpandedArrayHeader xpn;
> } AnyArrayType;
>
> ASAN seems to believe that use of this union entitles the compiler to
> assume 8-byte alignment even when touching fields of a short-header

In my understanding  union has to be aligned to ExpandedArrayHeader (8
bytes) or it's a UB.

On x64 it could be an issue if AnyArrayType alignment is less than 4,
sse is enable and suddenly compiler choose to use sse instructions
with 16 bytes requirement then compiler may not emit the right code.

It's not rhetorical, big surprise first time you get a SIGBUS signal,
or a SIGFPE doing integer math, on x64.

Regards
Didier



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

Предыдущее
От: Fabien COELHO
Дата:
Сообщение: Re: Why does pg_checksums -r not have a long option?
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Read-only access to temp tables for 2PC transactions