Re: PgStat_HashKey padding issue when passed by reference - Mailing list pgsql-hackers

From Sami Imseih
Subject Re: PgStat_HashKey padding issue when passed by reference
Date
Msg-id CAA5RZ0sit01ui8CqQgTTVLybq=TD3z1rgYTOH_Xz-MMKDe+f5g@mail.gmail.com
Whole thread Raw
In response to Re: PgStat_HashKey padding issue when passed by reference  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
> Did you run a full installcheck under valgrind to have more confidence
> that this is the only code path where we care about the padding of the
> passed-in values for the hash lookups?

I did and could not reproduce "Use of uninitialised value..." on HEAD.

I will mention that it's not a simple reproducible exercise, at least
I could not repro with a simple C program that compiled with -O2.

>> 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.

or instead of avoiding padding, we continue to do what we do which
is zeroing out the key when creating, but to make sure we pass it by
reference so the hash_hash/hash_compare functions are operating on the same
memor.I think that is all we really need. in v2 I added a comment
to clarify why pass-by-reference is needed.

Thoughts?

--
Sami

Attachment

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: GetNamedLWLockTranche crashes on Windows in normal backend
Next
From: Álvaro Herrera
Date:
Subject: Re: Potential problem in commit f777d773878 and 4f7f7b03758