Fix runtime errors from -fsanitize=undefined

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Fix runtime errors from -fsanitize=undefined
Дата
Msg-id e1a26ece-7057-a234-d87e-4ce1cdc9eaa0@2ndquadrant.com
обсуждение исходный текст
Ответы Re: Fix runtime errors from -fsanitize=undefined  (Robert Haas <robertmhaas@gmail.com>)
Re: Fix runtime errors from -fsanitize=undefined  (Noah Misch <noah@leadboat.com>)
Список pgsql-hackers
After many years of trying, it seems the -fsanitize=undefined checking
in gcc is now working somewhat reliably.  Attached is a patch that fixes
all errors of the kind

runtime error: null pointer passed as argument N, which is declared to
never be null

Most of the cases are calls to memcpy(), memcmp(), etc. with a length of
zero, so one appears to get away with passing a null pointer.

Note that these are runtime errors, not static analysis, so the code in
question is actually reached.

To reproduce, configure normally and then set

COPT=-fsanitize=undefined -fno-sanitize=alignment -fno-sanitize-recover=all

and build and run make check-world.  Unpatched, this will core dump in
various places.

(-fno-sanitize=alignment should also be fixed but I took it out here to
deal with it separately.)

See https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html for
further documentation.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Pinned files at Windows
Следующее
От: Melanie Plageman
Дата:
Сообщение: Sort support for macaddr8