Re: How to test Postgres for any unaligned memory accesses? - Mailing list pgsql-hackers

From Bharath Rupireddy
Subject Re: How to test Postgres for any unaligned memory accesses?
Date
Msg-id CALj2ACU=OtVXRAJmcgNcWLdBmHiNxksuPEgdZD2hnCF8dGHHwg@mail.gmail.com
Whole thread Raw
In response to Re: How to test Postgres for any unaligned memory accesses?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Apr 23, 2021 at 7:25 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > I'm not sure this is the right way. I would like to know whether there
> > is a standard way of testing Postgres code for any unaligned memory
> > accesses. Thanks. Any help would be appreciated.
>
> Per c.h, late-model compilers have options for this:
>
>  * Testing can be done with "-fsanitize=alignment -fsanitize-trap=alignment"
>  * on clang, or "-fsanitize=alignment -fno-sanitize-recover=alignment" on gcc.

Thanks Tom!

I used the above gcc compiler flags to see if they catch memory
alignment issues. The way I tested on my dev system (x86_64 platform
with Ubuntu OS)  was that I commented out max aligning specialSize in
PageInit, compiled the source code with and without the alignment
flags. make check failed with the alignment checking flags, it passed
without the flags.

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: "tanghy.fnst@fujitsu.com"
Date:
Subject: RE: use pg_strncasecmp to replace strncmp when compare "pg_"
Next
From: Tom Lane
Date:
Subject: Re: Does rewriteTargetListIU still need to add UPDATE tlist entries?