asan_test.C: disable -Wstringop-overflow, PR/93058
diff mbox series

Message ID 20200124075722.2074922-1-slyfox@inbox.ru
State New
Headers show
Series
  • asan_test.C: disable -Wstringop-overflow, PR/93058
Related show

Commit Message

Fangrui Song via gcc-patches Jan. 24, 2020, 7:57 a.m. UTC
From: Sergei Trofimovich <slyfox@inbox.ru>

From: Sergei Trofimovich <siarheit@google.com>

asan's test allocates 2 pages via pvalloc(kPageSize + 100)
and makes sure dereference of 'kPageSize + 101' does not
trigger asan checks.

glibc's and gcc's malloc-like attribute checkers trigger
a warning:
    asan_test.cc:129:22: error: writing 1 byte into a region
    of size 0 [-Werror=stringop-overflow=]

As there is no easy way to convey pvalloc()'s granularity
to gcc let's just disable the warning for this test.

	* g++.dg/asan/asan_test.C: disable -Wstringop-overflow.
---
 gcc/testsuite/ChangeLog               | 4 ++++
 gcc/testsuite/g++.dg/asan/asan_test.C | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Jakub Jelinek Jan. 24, 2020, 9:20 p.m. UTC | #1
On Fri, Jan 24, 2020 at 07:57:22AM +0000, slyfox.inbox.ru via gcc-patches wrote:
> From: Sergei Trofimovich <slyfox@inbox.ru>
> 
> From: Sergei Trofimovich <siarheit@google.com>
> 
> asan's test allocates 2 pages via pvalloc(kPageSize + 100)
> and makes sure dereference of 'kPageSize + 101' does not
> trigger asan checks.
> 
> glibc's and gcc's malloc-like attribute checkers trigger
> a warning:
>     asan_test.cc:129:22: error: writing 1 byte into a region
>     of size 0 [-Werror=stringop-overflow=]
> 
> As there is no easy way to convey pvalloc()'s granularity
> to gcc let's just disable the warning for this test.
> 
> 	* g++.dg/asan/asan_test.C: disable -Wstringop-overflow.

No.  That is a glibc bug and it has been fixed in glibc already, if we
disabled this, we might never discovered it.

	Jakub
Fangrui Song via gcc-patches Jan. 24, 2020, 10:23 p.m. UTC | #2
On Fri, 24 Jan 2020 22:20:43 +0100
Jakub Jelinek <jakub@redhat.com> wrote:

> On Fri, Jan 24, 2020 at 07:57:22AM +0000, slyfox.inbox.ru via gcc-patches wrote:
> > From: Sergei Trofimovich <slyfox@inbox.ru>
> > 
> > From: Sergei Trofimovich <siarheit@google.com>
> > 
> > asan's test allocates 2 pages via pvalloc(kPageSize + 100)
> > and makes sure dereference of 'kPageSize + 101' does not
> > trigger asan checks.
> > 
> > glibc's and gcc's malloc-like attribute checkers trigger
> > a warning:
> >     asan_test.cc:129:22: error: writing 1 byte into a region
> >     of size 0 [-Werror=stringop-overflow=]
> > 
> > As there is no easy way to convey pvalloc()'s granularity
> > to gcc let's just disable the warning for this test.
> > 
> > 	* g++.dg/asan/asan_test.C: disable -Wstringop-overflow.  
> 
> No.  That is a glibc bug and it has been fixed in glibc already, if we
> disabled this, we might never discovered it.

Aha, I assume it was fixed by https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=768c83b7f60d82db6677e19dc51be9f341e0f3fc

I'll close gcc PR as invalid then.

Thank you!

Patch
diff mbox series

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9a87cfe595b..847b73e7287 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@ 
+2020-01-24  Sergei Trofimovich <siarheit@google.com>
+
+	* g++.dg/asan/asan_test.C: disable -Wstringop-overflow.
+
 2020-01-22  Andrew Pinski  <apinski@marvell.com>
 
 	* tree-ssa.exp: Set DEFAULT_VECTCFLAGS and DEFAULT_VECTCFLAGS.
diff --git a/gcc/testsuite/g++.dg/asan/asan_test.C b/gcc/testsuite/g++.dg/asan/asan_test.C
index f3f7626ef3b..8e18744c7c6 100644
--- a/gcc/testsuite/g++.dg/asan/asan_test.C
+++ b/gcc/testsuite/g++.dg/asan/asan_test.C
@@ -2,7 +2,7 @@ 
 // { dg-skip-if "" { *-*-* } { "*" } { "-O2" } }
 // { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
 // { dg-additional-sources "asan_globals_test-wrapper.cc" }
-// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" }
+// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror -Wno-stringop-overflow -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" }
 // { dg-additional-options "-DASAN_NEEDS_SEGV=1" { target { ! arm*-*-* } } }
 // { dg-additional-options "-DASAN_LOW_MEMORY=1 -DASAN_NEEDS_SEGV=0" { target arm*-*-* } }
 // { dg-additional-options "-DASAN_AVOID_EXPENSIVE_TESTS=1" { target { ! run_expensive_tests } } }