Re: [HACKERS] SerializedSnapshotData alignment - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] SerializedSnapshotData alignment
Date
Msg-id 594.1488156795@sss.pgh.pa.us
Whole thread Raw
In response to [HACKERS] SerializedSnapshotData alignment  (Noah Misch <noah@leadboat.com>)
Responses Re: [HACKERS] SerializedSnapshotData alignment  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Noah Misch <noah@leadboat.com> writes:
> Dear 7b4ac19 authors,
> Field ps_snapshot_data usually receives four-byte alignment within
> ParallelIndexScanDescData, but it contains the eight-byte whenTaken field.
> The select_parallel test dies with SIGBUS on "Oracle Solaris 10 1/13
> s10s_u11wos_24a SPARC", building with gcc 4.9.2.

It's a little distressing that the buildfarm didn't find this already.
Is there some reason why it's specific to that particular compiler,
rather than generic to alignment-picky 64-bit machines?

In general, though, I agree that using a char[] member to represent
anything that has any alignment requirement at all is seriously bad
coding style that is almost certain to fail eventually.

A solution you didn't mention is to change the ParallelIndexScanDescData
field to be a pointer, perhaps "struct SerializedSnapshotData *", while
leaving that struct opaque so far as relscan.h is concerned.  This could
avoid the need to use the unsafe blind casts that I'm sure must be
involved in accesses to that field at present.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] IF (NOT) EXISTS in psql-completion
Next
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Proposal for changes to recovery.conf API