GIST code doesn't build on strict 64-bit machines

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>, Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: GIST code doesn't build on strict 64-bit machines
Date: 2004-03-26 21:30:39
Message-ID: 27415.1080336639@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Huxton 2004-03-26 21:43:28 Re: Per database users/admins,
Previous Message Sean Chittenden 2004-03-26 20:36:47 Re: Per database users/admins, handy for database virtual hosting...