From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Avoid faulty alignment of Datums in build_sorted_items(). |
Date: | 2025-09-10 21:51:31 |
Message-ID: | E1uwSix-0004y4-1L@gemulon.postgresql.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Avoid faulty alignment of Datums in build_sorted_items().
If sizeof(Pointer) is 4 then sizeof(SortItem) will be 12, so that
if data->numrows is odd then we placed the values array at a location
that's not a multiple of 8. That was fine when sizeof(Datum) was also
4, but in the wake of commit 2a600a93c it makes some alignment-picky
machines unhappy. (You need a 32-bit machine that nonetheless expects
8-byte alignment of 8-byte quantities, which is an odd-seeming
combination but it does exist outside the Intel universe.)
To fix, MAXALIGN the space allocated to the SortItem array.
In passing, let's make the "len" variable be Size not int,
just for paranoia's sake.
This code was arguably not too safe even before 2a600a93c, but at
present I don't see a strong argument for back-patching.
Reported-by: Tomas Vondra <tomas(at)vondra(dot)me>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/87036018-8d70-40ad-a0ac-192b07bd7b04@vondra.me
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/09036dc71c682b0bf7234ed39c1429ed99fbe442
Modified Files
--------------
src/backend/statistics/extended_stats.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-09-11 01:16:08 | pgsql: Fix incorrect file reference in guc.h |
Previous Message | Tom Lane | 2025-09-10 20:15:13 | pgsql: Fix memory leakage in nodeSubplan.c. |