Ensuring hash tuples are properly maxaligned
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>,
Thomas Munro <thomas.munro@enterprisedb.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2018-01-03T00:08:49Z
Lists: pgsql-hackers
Attachments
- ensure-proper-hash-tuple-alignment.patch (text/x-diff) patch
I've been poking around in the PHJ code trying to identify the reason why there are still so many buildfarm failures. I've not nailed it down yet, but one thing I did notice is that there's an entirely undocumented assumption that offsetof(HashMemoryChunkData, data) is maxalign'ed. If it isn't, the allocation code will give back non- maxaligned pointers, which will appear to work as long as you only test on alignment-lax processors. Now, the existing definition of the struct seems safe on all architectures we support, but it would not take much to break it. I think we ought to do what we did recently in the memory-context code: insert an explicit padding calculation and a static assertion that it's right. Hence, the attached proposed patch (in which I also failed to resist the temptation to make the two code paths in dense_alloc() look more alike). Any objections? regards, tom lane
Commits
-
Ensure proper alignment of tuples in HashMemoryChunkData buffers.
- 5dc692f78d3b 11.0 landed