This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Support -fsanitize=leak
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Dodji Seketeli <dodji at redhat dot com>
- Cc: Konstantin Serebryany <konstantin dot s dot serebryany at gmail dot com>, Ian Lance Taylor <iant at google dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Nov 2013 21:53:31 +0100
- Subject: Re: [PATCH] Support -fsanitize=leak
- Authentication-results: sourceware.org; auth=none
- References: <20131115194138 dot GQ892 at tucnak dot redhat dot com> <87r4a8f9ke dot fsf at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Nov 22, 2013 at 09:47:13PM +0100, Dodji Seketeli wrote:
> > This patch adds support for -fsanitize=leak and -static-liblsan options.
> > If combined with -fsanitize=address, it does nothing,
>
> >From this hunk:
>
> @@ -8123,7 +8133,10 @@ sanitize_spec_function (int argc, const
> return (flag_sanitize & SANITIZE_THREAD) ? "" : NULL;
> if (strcmp (argv[0], "undefined") == 0)
> return (flag_sanitize & SANITIZE_UNDEFINED) ? "" : NULL;
> -
> + if (strcmp (argv[0], "leak") == 0)
> + return ((flag_sanitize
> + & (SANITIZE_ADDRESS | SANITIZE_LEAK | SANITIZE_THREAD))
> + == SANITIZE_LEAK) ? "" : NULL;
> return NULL;
> }
>
> I'd say if combined with -fsanitize={address,thread} it does nothing,
> right?
Yes. The libasan library can do the leak detection too, though unlike
liblsan doesn't do it by default right now, needs to be enabled through
environment. Dunno about tsan, but all the 3 libraries certainly are
incompatible with each other.
Perhaps __asan_init_v3 could be changed to __asan_init_v4 and pass
some flags to the library, where one of the bits would be whether
to enable leak detector by default or not? Just a thought...
> I'd say this needs some tests as well, but I guess they are coming a
> bit later in the cycle?
Yeah.
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> Yes, this is OK with the incremental patch for the documentation.
Thanks.
Jakub