From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | rahilasyed90(at)gmail(dot)com, amit(dot)kapila16(at)gmail(dot)com, robertmhaas(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: SerializedSnapshotData alignment |
Date: | 2017-02-27 01:18:41 |
Message-ID: | 20170227011841.GC1480178@tornado.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Feb 26, 2017 at 07:53:15PM -0500, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)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?
I wondered the same thing; if nothing else, why don't protosciurus and
castoroides fail the same way? They do use older compilers, "Sun C 5.10
SunOS_sparc 2009/06/03" and gcc 3.4.3. I have "Sun C 5.12 SunOS_sparc
2011/11/16" and gcc 4.9.2, both of which are alignment-sensitive in several
configurations, according to the attached test program. However, in a 32-bit
build with this Sun C, I don't get alignment-related bus errors. (Those
animals build 64-bit, so this isn't the full story.)
> 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.
That, too, would be reasonable.
Attachment | Content-Type | Size |
---|---|---|
align.c | text/plain | 358 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-02-27 01:20:09 | Re: IF (NOT) EXISTS in psql-completion |
Previous Message | Michael Paquier | 2017-02-27 01:16:34 | Re: IF (NOT) EXISTS in psql-completion |