postgresql/src
John Naylor fd49e8f323 Prevent access of uninitialized memory in radix tree nodes
RT_NODE_16_SEARCH_EQ() performs comparisions using vector registers
on x64-64 and aarch64. We apply a mask to the resulting bitfield
to eliminate irrelevant bits that may be set. This ensures correct
behavior, but Valgrind complains of the partially-uninitialised
values. So far the warnings have only occurred on aarch64, which
explains why this hasn't been seen earlier.

To fix this warning, initialize the whole fixed-sized part of the nodes
upon allocation, rather than just do the minimum initialization to
function correctly. The initialization for node48 is a bit different
in that the 256-byte slot index array must be populated with "invalid
index" rather than zero. Experimentation has shown that compilers
tend to emit code that uselessly memsets that array twice. To avoid
pessimizing this path, swap the order of the slot_idxs[] and isset[]
arrays so we can initialize with two non-overlapping memset calls.

Reported by Tomas Vondra
Analysis and patch by Tom Lane, reviewed by Masahiko Sawada. I
investigated the behavior of memset calls to overlapping regions,
leading to the above tweaks to node48 as discussed in the thread.

Discussion: https://postgr.es/m/120c63ad-3d12-415f-a7bf-3da451c31bf6%40enterprisedb.com
2024-06-21 17:29:39 +07:00
..
backend Fix make build on MinGW 2024-06-21 08:17:23 +02:00
bin pg_combinebackup: Error message improvements 2024-06-21 09:40:44 +02:00
common parse_manifest: Use const char * 2024-06-21 07:53:30 +02:00
fe_utils Fix PL/pgSQL's handling of integer ranges containing underscores. 2024-06-04 11:48:01 +01:00
include Prevent access of uninitialized memory in radix tree nodes 2024-06-21 17:29:39 +07:00
interfaces Improve the granularity of PQsocketPoll's timeout parameter. 2024-06-13 15:14:32 -04:00
makefiles Optimize pg_popcount() with AVX-512 instructions. 2024-04-06 21:56:23 -05:00
pl When replanning a plpgsql "simple expression", check it's still simple. 2024-06-13 13:37:49 -04:00
port Pre-beta mechanical code beautification. 2024-05-14 16:34:50 -04:00
template Remove AIX support 2024-02-28 15:17:23 +04:00
test Don't throw an error if a queued AFTER trigger no longer exists. 2024-06-20 14:21:36 -04:00
timezone Update time zone data files to tzdata release 2024a. 2024-02-01 15:57:53 -05:00
tools Improve the granularity of PQsocketPoll's timeout parameter. 2024-06-13 15:14:32 -04:00
tutorial Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Update Unicode data to CLDR 45 2024-04-22 09:16:33 +02:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00