This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix asan regtest failures c-c++-common/asan/{memcmp-1.c,strncpy-overflow-1.c}


Hello,

Since a couple of days I am seeing failure on the tests above on my
Fedora system.  The errors look like:

FAIL: c-c++-common/asan/memcmp-1.c  -O0  output pattern test, is =================================================================
==21832==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff75df96f4 at pc 0x7f98ecbab68b bp 0x7fff75df96b0 sp 0x7fff75df95b8
READ of size 6 at 0x7fff75df96f4 thread T0
    #0 0x7f98ecbab68a in __interceptor_memcmp /home/dodji/git/gcc/master/libsanitizer/asan/asan_interceptors.cc:295 (discriminator 7)
    #1 0x7f98ecbb6393 in __asan_report_error /home/dodji/git/gcc/master/libsanitizer/asan/asan_report.cc:774 (discriminator 9)
    #2 0x7f98ecbab6d0 in __interceptor_memcmp /home/dodji/git/gcc/master/libsanitizer/asan/asan_interceptors.cc:295 (discriminator 7)
    #3 0x400b0a in main /home/dodji/git/gcc/master/gcc/testsuite/c-c++-common/asan/memcmp-1.c:14
    #4 0x3380821a04 in __libc_start_main ??:?
    #5 0x4007b8 in _start ??:?
Address 0x7fff75df96f4 is located in stack of thread T0 at offset 36 in frame
    #0 0x40089f in main /home/dodji/git/gcc/master/gcc/testsuite/c-c++-common/asan/memcmp-1.c:11

[...]

and

FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  output pattern test, is =================================================================
==30666==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000efd9 at pc 0x7f65c09fd8f9 bp 0x7fffd820d170 sp 0x7fffd820d0a0
WRITE of size 10 at 0x60200000efd9 thread T0
    #0 0x7f65c09fd8f8 in __interceptor_strncpy /home/dodji/git/gcc/master/libsanitizer/asan/asan_interceptors.cc:509 (discriminator 7)
    #1 0x7f65c0a06393 in __asan_report_error /home/dodji/git/gcc/master/libsanitizer/asan/asan_report.cc:774 (discriminator 9)
    #2 0x7f65c09fd93e in __interceptor_strncpy /home/dodji/git/gcc/master/libsanitizer/asan/asan_interceptors.cc:509 (discriminator 7)
    #3 0x400a9c in main /home/dodji/git/gcc/master/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c:11
    #4 0x3380821a04 in __libc_start_main ??:?
    #5 0x400898 in _start ??:?
0x60200000efd9 is located 0 bytes to the right of 9-byte region [0x60200000efd0,0x60200000efd9)
allocated by thread T0 here:
    #0 0x7f65c0a00cd9 in __interceptor_malloc /home/dodji/git/gcc/master/libsanitizer/asan/asan_malloc_linux.cc:72 (discriminator 9)
    #1 0x400a80 in main /home/dodji/git/gcc/master/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c:10

[...]

It turned out this is just due to the output emitted by the
AddressSanitizer that has changed.

The patch below just adapts the regexps of the above test to match
the fact that a few new line patterns were inserted in the middle of
the output.

It also fixes what I think are typos namely, un-escaped ']' as in
"\[something]".  I believe the closing square bracket should be
escaped as well (but well, how do I know about tcl really).

Tested on x86_64-unknown-linux-gnu against trunk.

gcc/testsuite/ChangeLog:

	* c-c++-common/asan/memcmp-1.c: Adapt the pattern for changed
	libsanitizer output.
	* c-c++-common/asan/strncpy-overflow-1.c: Likewise.
---
 gcc/testsuite/c-c++-common/asan/memcmp-1.c           | 8 ++++++--
 gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c | 9 +++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/asan/memcmp-1.c b/gcc/testsuite/c-c++-common/asan/memcmp-1.c
index 03f32e9..9a62e33 100644
--- a/gcc/testsuite/c-c++-common/asan/memcmp-1.c
+++ b/gcc/testsuite/c-c++-common/asan/memcmp-1.c
@@ -16,5 +16,9 @@ main ()
 }
 
 /* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow.*(\n|\r\n|\r)" } */
-/* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)memcmp |\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)memcmp |\[(\])\[^\n\r\]*(\n|\r\n|\r)" } */
+/* { dg-output "(\[^\r\n\]*(\n|\r\n|\r))+" } */
+/* { dg-output "    #\[0-9\]+ 0x\[0-9a-f\]+ in main"} */
+/* { dg-output "(\[^\r\n\]*(\n|\r\n|\r))+" } */
+/* { dg-output "Address 0x\[0-9a-f\] is located in stack of thread T0 at offset \[0-9\]+ in frame (\n|\r\n|\r)"} */
+/* { dg-output "    #0 0x\[0-9a-f\]+ in main" } */
diff --git a/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c b/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
index 3ed9fd6..b1a4cda 100644
--- a/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
+++ b/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
@@ -13,9 +13,10 @@ int main(int argc, char **argv) {
 }
 
 /* { dg-output "WRITE of size \[0-9\]* at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)strncpy|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*strncpy-overflow-1.c:11|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)strncpy|\[(\])\[^\n\r\]*(\n|\r\n|\r)" } */
+/* { dg-output "(\[^\r\n\]*(\n|\r\n|\r))+" } */
+/* { dg-output "    #\[0-9\]+ 0x\[0-9a-f\]+ in main"} */
+/* { dg-output "\[^\n\r\]*0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*strncpy-overflow-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #1 0x\[0-9a-f\]+ (in main (\[^\n\r\]*strncpy-overflow-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-- 
		Dodji


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]