[PATCH] Support -fsanitize=leak

Jakub Jelinek jakub@redhat.com
Sat Nov 23 03:19:00 GMT 2013


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



More information about the Gcc-patches mailing list