Re: Fix misaligned access of ItemPointerData on ARM - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Fix misaligned access of ItemPointerData on ARM
Date
Msg-id 20150521195610.GA2028@alap3.anarazel.de
Whole thread Raw
In response to Re: Fix misaligned access of ItemPointerData on ARM  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2015-05-21 15:34:00 -0400, Tom Lane wrote:
> Piotr Stefaniak <postgres@piotr-stefaniak.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
identifierfor 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.



pgsql-hackers by date:

Previous
From: Paul Ramsey
Date:
Subject: GiST KNN Crasher
Next
From: Tom Lane
Date:
Subject: Re: Fix misaligned access of ItemPointerData on ARM