Re: How to test Postgres for any unaligned memory accesses?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to test Postgres for any unaligned memory accesses?
Дата
Msg-id 1312608.1619186109@sss.pgh.pa.us
обсуждение исходный текст
Ответ на How to test Postgres for any unaligned memory accesses?  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Ответы Re: How to test Postgres for any unaligned memory accesses?
Список pgsql-hackers
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> writes:
> I'm trying to test Postgres code for any unaligned memory accesses. I
> used a hack shown at [1] and put it in exec_simple_query, then I'm
> seeing a SIGBUS error from SplitIdentifierString's strncpy, see [2].

Regardless of Postgres' policy about alignment safety, glibc sees
no reason to avoid unaligned accesses on x86 hardware.  If you want
to test this sort of thing on hardware that's not actually alignment
picky, you have to enlist the toolchain's help.

> 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.

We have at least one buildfarm member using the former.  I have no idea
how water-tight these checks are though.  They don't seem to cause very
much slowdown, which is suspicious :-(

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "osumi.takamichi@fujitsu.com"
Дата:
Сообщение: RE: Truncate in synchronous logical replication failed
Следующее
От: "osumi.takamichi@fujitsu.com"
Дата:
Сообщение: RE: Forget close an open relation in ReorderBufferProcessTXN()