Re: PgStat_HashKey padding issue when passed by reference

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: PgStat_HashKey padding issue when passed by reference
Дата
Msg-id aL9zo5X0MsSxO2pM@paquier.xyz
обсуждение исходный текст
Ответ на Re: PgStat_HashKey padding issue when passed by reference  (Andres Freund <andres@anarazel.de>)
Ответы Re: PgStat_HashKey padding issue when passed by reference
Список pgsql-hackers
On Mon, Sep 08, 2025 at 12:08:12PM -0400, Andres Freund wrote:
> On 2025-09-08 10:25:13 +0900, Michael Paquier wrote:
>> Another idea would be to make sure that the sizeof() of the structure
>> matches with the sum of the sizeof() for the individual fields in it.
>> That's cumbersome to rely on, still simpler.  Perhaps we could do
>> something among these lines for pgstat_shmem.c, or just document that
>> the structure should never have any padding.
>
> I'd just add a comment mentioning that any padding bytes should be avoided.

Agreed on this part.

I am wondering also about the addition of a static assertion as well,
as it seems that this thread and the opinions on it point to such an
addition having value, and requiring valgrind to detect that is
annoying, especially if people propose more patches in the future that
may affect the way we pass the hash key values in this area of the
code.  An idea is attached.
--
Michael

Вложения

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