Fix some ubsan/asan related issues

Поиск
Список
Период
Сортировка
От Tristan Partin
Тема Fix some ubsan/asan related issues
Дата
Msg-id CYS5XJ2E49Y5.27QXHL4X2484A@neon.tech
обсуждение исходный текст
Ответы Re: Fix some ubsan/asan related issues  (Heikki Linnakangas <hlinnaka@iki.fi>)
Re: Fix some ubsan/asan related issues  (Alexander Lakhin <exclusion@gmail.com>)
Список pgsql-hackers
Patch 1:

Passing NULL as a second argument to memcpy breaks ubsan, and there
didn't seem to be anything preventing that in the LogLogicalMessage()
codepath. Here is a preventative measure in LogLogicalMessage() and an
Assert() in CopyXLogRecordToWAL().

Patch 2:

Support building with -Db_sanitize=address in Meson. Various executables
are leaky which can cause the builds to fail and tests to fail, when we
are fine leaking this memory.

Personally, I am a big stickler for always freeing my memory in
executables even if it gets released at program exit because it makes
the leak sanitizer much more effective. However (!), I am not here to
change the philosophy of memory management in one-off executables, so
I have just silenced memory leaks in various executables for now.

Patch 3:

THIS DOESN'T WORK. DO NOT COMMIT. PROPOSING FOR DISCUSSION!

In my effort to try to see if the test suite would pass with asan
enabled, I ran into a max_stack_depth issue. I tried maxing it out
(hence, the patch), but that still didn't remedy my issue. I tried to
look on the list for any relevant emails, but nothing turned up. Maybe
others have not attempted this before? Seems doubtful.

Not entirely sure how to fix this issue. I personally find asan
extremely effective, even more than valgrind, so it would be great if
I could run Postgres with asan enabled to catch various stupid C issues
I might create. On my system, ulimit -a returns 8192 kbytes, so Postgres
just lets me set 7680 kbytes as the max. Whatever asan is doing doesn't
seem to leave enough stack space for Postgres.

---

I would like to see patch 1 reviewed and committed. Patch 2 honestly
doesn't matter unless asan support can be fixed. I can also add a patch
that errors out the Meson build if asan support is requested. That way
others don't spend time heading down a dead end.

--
Tristan Partin
Neon (https://neon.tech)



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: cleanup patches for incremental backup
Следующее
От: "Tristan Partin"
Дата:
Сообщение: Re: Fix some ubsan/asan related issues