[PATCH 2/2] Libsanitizer merge from upstream r253555.

Jakub Jelinek jakub@redhat.com
Mon Nov 23 08:20:00 GMT 2015


On Mon, Nov 23, 2015 at 10:48:30AM +0300, Maxim Ostapenko wrote:
> Index: gcc/testsuite/c-c++-common/asan/halt_on_error-1.c
> ===================================================================
> --- gcc/testsuite/c-c++-common/asan/halt_on_error-1.c	(revision 0)
> +++ gcc/testsuite/c-c++-common/asan/halt_on_error-1.c	(working copy)
> @@ -0,0 +1,23 @@
> +/* Test recovery mode.  */
> +/* { dg-do run } */
> +/* { dg-options "-fsanitize-recover=address" } */
> +/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=false" } */
> +
> +#include <string.h>
> +
> +volatile int ten = 10;
> +
> +int main() {
> +  char x[10];
> +  memset(x, 0, 11);

Please use ten + 1 instead of 11 here.
With -fsanitize=address, there will be padding immediately after the
variable, therefore otherwise (if the compiler does not see we are
running into undefined behavior) the testcase might be ok.

> --- gcc/testsuite/c-c++-common/asan/halt_on_error-2.c	(revision 0)
> +++ gcc/testsuite/c-c++-common/asan/halt_on_error-2.c	(working copy)
> @@ -0,0 +1,24 @@
> +/* Test recovery mode.  */
> +/* { dg-do run } */
> +/* { dg-options "-fsanitize-recover=address" } */
> +/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=true" } */
> +/* { dg-shouldfail "asan" } */
> +
> +#include <string.h>
> +
> +volatile int ten = 10;
> +
> +int main() {
> +  char x[10];
> +  memset(x, 0, 11);

Likewise.

Otherwise OK for trunk.

	Jakub



More information about the Gcc-patches mailing list