Re: Detecting pointer misalignment (was Re: pgsql: Implementation of subscripting for jsonb)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Alexander Korotkov <akorotkov(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Detecting pointer misalignment (was Re: pgsql: Implementation of subscripting for jsonb)
Date: 2021-02-08 16:49:41
Message-ID: 628089.1612802981@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

I wrote:
> After digging in gcc's release history, it seems they invented
> "-fsanitize=alignment" in GCC 5, so we can make this work for gcc
> by writing
> #if __GNUC__ >= 5
> (the likely() macro already uses a similar approach). Can't say
> if that's close enough for clang too.

Ugh, no it isn't: even pretty recent clang releases only define
__GNUC__ as 4. It looks like we need a separate test on clang's
version. I looked at their version history and sanitizers seem
to have come in around clang 7, so I propose the attached (where
I worked a bit harder on the comment, too).

regards, tom lane

Attachment Content-Type Size
pg_attribute_no_sanitize_alignment-2.patch text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2021-02-08 17:29:34 pgsql: Translation updates
Previous Message Tom Lane 2021-02-08 16:11:02 pgsql: Last-minute updates for release notes.

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira 2021-02-08 16:51:08 Re: pg_replication_origin_drop API potential race condition
Previous Message Tom Lane 2021-02-08 16:14:24 Re: Made ecpg compatibility mode and run-time behaviour options case insensitive