pgsql: Fix valgrind's "unaddressable bytes" whining about BRIN code.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix valgrind's "unaddressable bytes" whining about BRIN code.
Дата
Msg-id E1Yx46Q-0004fM-Pp@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix valgrind's "unaddressable bytes" whining about BRIN code.

brin_form_tuple calculated an exact tuple size, then palloc'd and
filled just that much.  Later, brin_doinsert or brin_doupdate would
MAXALIGN the tuple size and tell PageAddItem that that was the size
of the tuple to insert.  If the original tuple size wasn't a multiple
of MAXALIGN, the net result would be that PageAddItem would memcpy
a few more bytes than the palloc request had been for.

AFAICS, this is totally harmless in the real world: the error is a
read overrun not a write overrun, and palloc would certainly have
rounded the request up to a MAXALIGN multiple internally, so there's
no chance of the memcpy fetching off the end of memory.  Valgrind,
however, is picky to the byte level not the MAXALIGN level.

Fix it by pushing the MAXALIGN step back to brin_form_tuple.  (The other
possible source of tuples in this code, brin_form_placeholder_tuple,
was already producing a MAXALIGN'd result.)

In passing, be a bit more paranoid about internal allocations in
brin_form_tuple.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/79f2b5d583e2e2a7ccd13e31d0e20a900c8f2f61

Modified Files
--------------
src/backend/access/brin/brin_pageops.c |    4 ++--
src/backend/access/brin/brin_tuple.c   |   15 +++++++++++----
2 files changed, 13 insertions(+), 6 deletions(-)


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: pgsql: pgindent: document location of "all" typedef lists
Следующее
От: Andrew Dunstan
Дата:
Сообщение: pgsql: Add all structured objects passed to pushJsonbValue piecewise.