On Wed, Sep 28, 2016 at 7:40 AM, Piotr Stefaniak <postg...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers