GIST code doesn't build on strict 64-bit machines - Mailing list pgsql-hackers

From Tom Lane
Subject GIST code doesn't build on strict 64-bit machines
Date
Msg-id 27415.1080336639@sss.pgh.pa.us
Whole thread Raw
Responses Re: GIST code doesn't build on strict 64-bit machines
List pgsql-hackers
I've just found out the hard way that Postgres doesn't even build on
recent gcc releases for 64-bit HPPA.  The reason is that the compiler
now notices and complains about alignment errors that will lead to
core dump at runtime, and GIST has got some.  The particular code that
fails to compile is in gist.c:               gistentryinit(((GISTENTRY *) VARDATA(evec))[1],
((GISTENTRY*) VARDATA(evec))[0].key, r, NULL,                             (OffsetNumber) 0, ((GISTENTRY *)
VARDATA(evec))[0].bytes,FALSE);
 

Since VARDATA() is at a 4-byte offset from the start of the datum, this
is trying to overlay a GISTENTRY struct at a 4-byte boundary.  When
compiling in 64-bit mode, Datum is 8 bytes, and so the GISTENTRY struct
is not sufficiently well aligned.  Unlike Intel machines, the HP chips
*require* 8-byte loads and stores to be 8-byte-aligned.

I suppose that a correct fix involves doing MAXALIGN(VARDATA(evec)),
but I do not know what places need to change to support this.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Richard Huxton"
Date:
Subject: Re: Per database users/admins,
Next
From: Kris Jurka
Date:
Subject: Re: Bad timestamp external representation