[PATCH 5/6] Add LSan annotation to ignore a memory leak
peter at lekensteyn.nl
Wed Jul 22 21:40:41 CEST 2015
On Wed, Jul 22, 2015 at 03:06:53PM +0200, Werner Koch wrote:
> On Thu, 9 Jul 2015 17:11, peter at lekensteyn.nl said:
> > I am not happy with the method to detect LSan availability, but here I
> > hope to solicit for some feedback. Should the code really be added to
> Adding a __GNUC__ condition would make it more portable. I like this
> style of annotations and they are useful for other code as well.
LSan is also supported by the Clang compiler, how would adding __GNUC__
make the definition more portable?
> libgpg-error is used by all GnuPG code and thus it might be useful to
> add this annotation macros to gpg-error.h.
I thought that LSan detection could be improved
(http://stackoverflow.com/q/31273016/427545), but looking at Chromium,
they seem to set cflags, ldflags (-fsanitize=leak) and macros (including
LEAK_SANITIZER) depending on the build config.
Ah well, those who use -fsanitize=threads or -fsanitize=leaks can also
set -DLEAK_SANITIZER themselves. I should probably add a comment for
that in the patch.
> > mpiutil? Or let the caller (tests/mpitests.c) handle leaks?
> In GnuPG we have a register_mem_cleanup_func to run free with atexit but
> that is not appropriate for a library. I think such annotations are a
> better way.
I will look at adding this to libgpg-error. Is src/gpg-error.h.in the
appropriate file for this? Can the patch be submitted to this list?
More information about the Gcrypt-devel