Re: LLVM Address Sanitizer (ASAN) and valgrind support

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: LLVM Address Sanitizer (ASAN) and valgrind support
Дата
Msg-id CAM-w4HNDJ_n0xKuEyXYc6WExgHP3Oz1XVQbNwtSEfhK7=Tbh_w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: LLVM Address Sanitizer (ASAN) and valgrind support  (Piotr Stefaniak <postgres@piotr-stefaniak.me>)
Список pgsql-hackers
On Wed, Sep 28, 2016 at 7:40 AM, Piotr Stefaniak
<postgres@piotr-stefaniak.me> wrote:
> Not remembering the context, I was initially confused about what exactly
> supposedly needs to be done in order to have ASan support, especially
> since I've been using it for a couple of years without any kind of
> modifications. Having read the whole thread now, I assume the discussion
> is now about getting MSan support, since apparently it's been already
> concluded that not much is needed for getting ASan support:


The differnce between msan and asan is only related to whether
uninitialized reads are tracked. All other memory errors such as
reading past the end of an allocation or reading after a free are
tracked by both.

Without asan support in Postgres's memdebug.h asan will just track
whether you're using memory that is outside the memory that malloc has
handed Postgres. It doesn't know anything about whether that memory
has been returned by palloc or has since been pfree'd. Even the bounds
checking is not great since you could be reading from palloc's header
or from the bytes in the next palloc block that happened to be
returned by the same malloc (or another malloc if you're unlucky).

The support I added to memdebug.h called macros which call llvm
intrinsics to mark the memory malloc'd by Postgres as unusuable until
it's returned by palloc. Once it's returned by palloc it's marked
usable except for a "guard" byte at the end. Then pfree marks the
memory unusable again. This basically mimics the behaviour you would
get from asan if you were using malloc directly.

I added support for msan as well which is basically just one more
macro to make the distinction between usable but uninitialized memory
and usable and initialized memory. But I was unable to test it because
msan didn't work for me at all. This seems to be the way of things
with llvm. It's great stuff but there's always 10% that is broken
because there's some cool new thing that's better.

-- 
greg



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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Password identifiers, protocol aging and SCRAM protocol
Следующее
От: Etsuro Fujita
Дата:
Сообщение: Re: Push down more full joins in postgres_fdw