Re: Fix misaligned access of ItemPointerData on ARM

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix misaligned access of ItemPointerData on ARM
Date: 2015-05-21 19:56:10
Message-ID: 20150521195610.GA2028@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-05-21 15:34:00 -0400, Tom Lane wrote:
> Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me> writes:
> > But due to how ExecRowMark struct is laid out in memory, the packed
> > struct ItemPointerData begins at an uneven offset, leading to misaligned
> > access whenever BlockIdData is set by ItemPointerSetInvalid() (and
> > likely in some other places, too).
>
> But BlockIdData is laid out and accessed as two 16-bit fields, so there
> should be no problem. On what platform exactly do you see a failure?

It's probably aligned on a byte boundary:

typedef struct ExecRowMark
{
Relation relation; /* opened and suitably locked relation */
Index rti; /* its range table index */
Index prti; /* parent range table index, if child */
Index rowmarkId; /* unique identifier for resjunk columns */
RowMarkType markType; /* see enum in nodes/plannodes.h */
bool noWait; /* NOWAIT option */
ItemPointerData curCtid; /* ctid of currently locked tuple, if any */
} ExecRowMark;

due to the packedness curCtid will quite possibly be stored without any
padding after after noWait.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-05-21 20:08:23 Re: Fix misaligned access of ItemPointerData on ARM
Previous Message Paul Ramsey 2015-05-21 19:56:05 GiST KNN Crasher