pgsql: Adjust SP-GiST WAL record formats to reduce alignment padding. - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Adjust SP-GiST WAL record formats to reduce alignment padding.
Date
Msg-id E1WsUSI-0003Rc-PT@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Adjust SP-GiST WAL record formats to reduce alignment padding.

The way the code was written, the padding was copied from uninitialized
memory areas.. Because the structs are local variables in the code where
the WAL records are constructed, making them larger and zeroing the padding
bytes would not make the code very pretty, so rather than fixing this
directly by zeroing out the padding bytes, it seems more clear to not try to
align the tuples in the WAL records. The redo functions are taught to copy
the tuple header to a local variable to avoid unaligned access.

Stable-branches have the same problem, but we can't change the WAL format
there, so fix in master only. Reading a few random extra bytes at the stack
is harmless in practice, so it's not worth crafting a different
back-patchable fix.

Per reports from Kevin Grittner and Andres Freund, using clang static
analyzer and Valgrind, respectively.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/8776faa81cb651322b8993422bdd4633f1f6a487

Modified Files
--------------
src/backend/access/spgist/spgdoinsert.c |   26 +++----
src/backend/access/spgist/spgvacuum.c   |    3 +-
src/backend/access/spgist/spgxlog.c     |  116 +++++++++++++++++++------------
src/include/access/spgist_private.h     |   38 +++++-----
src/include/access/xlog_internal.h      |    2 +-
5 files changed, 105 insertions(+), 80 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Tweak new regression test case for better portability.
Next
From: Andres Freund
Date:
Subject: pgsql: Move regression test listing of builtin leakproof functions to o