This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix handling of -fsanitize-recover* options.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Liška <mliska at suse dot cz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 23 Sep 2016 14:48:13 +0200
- Subject: Re: [PATCH] Fix handling of -fsanitize-recover* options.
- Authentication-results: sourceware.org; auth=none
- References: <0c0c51b5-8f69-2d64-c967-b859b38b71ac@suse.cz>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Sep 23, 2016 at 01:53:48PM +0200, Martin Liška wrote:
> 3) -fsanitize=leak is combinable with -fsanitize=address or
> -fsanitize=thread
Is it really combinable with -fsanitize=thread? I thought only libasan
or liblsan provides the leak checker. Anyway, I can't find where in the
patch you change this.
> --- a/gcc/flag-types.h
> +++ b/gcc/flag-types.h
> @@ -203,25 +203,25 @@ enum vect_cost_model {
> /* Different instrumentation modes. */
> enum sanitize_code {
> /* AddressSanitizer. */
> - SANITIZE_ADDRESS = 1 << 0,
> - SANITIZE_USER_ADDRESS = 1 << 1,
> - SANITIZE_KERNEL_ADDRESS = 1 << 2,
> + SANITIZE_ADDRESS = 1UL<< 0,
Formatting, space in between UL and << (many times).
> @@ -1516,11 +1518,18 @@ parse_sanitizer_options (const char *p, location_t loc, int scode,
> error_at (loc, "-fsanitize=all option is not valid");
> }
> else
> - flags |= ~(SANITIZE_USER_ADDRESS | SANITIZE_THREAD
> - | SANITIZE_LEAK);
> + flags |= ~(SANITIZE_THREAD | SANITIZE_LEAK
> + | SANITIZE_UNREACHABLE | SANITIZE_RETURN);
This change will turn on -fsanitize-recove=address for -fsanitize-recover=all, right?
That is quite a significant behavior change, isn't it? Have you checked
what clang does here?
> }
> else if (value)
> - flags |= sanitizer_opts[i].flag;
> + {
> + flags |= sanitizer_opts[i].flag;
> + /* Do not enable -fsanitize-recover=unreachable and
> + -fsanitize-recover=return if -fsanitize-recover=undefined
> + is selected. */
> + if (sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
> + flags &= ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN);
This looks wrong. If you want to complain about
-fsanitize-recover=unreachable, the above would be silent about
-fsanitize-recover=unreachable -fsanitize-recover=undefined.
Shouldn't it be instead
if (sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
flags |= SANITIZE_UNDEFINED & ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN);
else
flags |= sanitizer_opts[i].flag;
?
Jakub