From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30747 invoked by alias); 5 Dec 2012 12:29:28 -0000 Received: (qmail 30733 invoked by uid 22791); 5 Dec 2012 12:29:25 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_LV,TW_NW X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Dec 2012 12:29:13 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qB5CTAiP010994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Dec 2012 07:29:10 -0500 Received: from zalov.redhat.com (vpn1-5-46.ams2.redhat.com [10.36.5.46]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB5CT8eJ015563 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 5 Dec 2012 07:29:09 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qB5CT7cd002657; Wed, 5 Dec 2012 13:29:07 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qB5CT68p002656; Wed, 5 Dec 2012 13:29:06 +0100 Date: Wed, 05 Dec 2012 12:29:00 -0000 From: Jakub Jelinek To: Wei Mi Cc: Mike Stump , GCC Patches , David Li , Diego Novillo , Kostya Serebryany , Dodji Seketeli Subject: [PATCH] asan unit tests from llvm lit-test incremental changes Message-ID: <20121205122906.GO2315@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20121128101420.GG2315@tucnak.redhat.com> <20121203110018.GR2315@tucnak.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00304.txt.bz2 Hi! On Tue, Dec 04, 2012 at 10:00:35AM -0800, Wei Mi wrote: > I updated the patch according to the comments. Please take a look. Thanks. Rather than several further rounds of review, let me post an incremental patch on top of yours. Your patch seems to be incomplete BTW, that asan-special.exp and tests needing it weren't added. Let's resolve what you've posted first and look at the rest as a follow-up. With this patch as well as the two patches I've posted today, http://gcc.gnu.org/ml/gcc-patches/2012-12/msg00301.html http://gcc.gnu.org/ml/gcc-patches/2012-12/msg00302.html on top of your patch there are no testsuite failures on x86_64-linux during make check-gcc check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp' beyond the preexisting asan_test.C failures. The patch combines tiny cleanups (whitespace, * sizeof(char), etc.), avoiding relying on argc being 1 (not the case for some bare metal targets if we ever support them), some dg-options tweaks (e.g. global-overflow-1.c clearly assumes non-optimizing compiler, with memset (YYY, 0, sizeof (YYY)); int res = YYY[ten]; the FRE pass happily optimizes the read into 0, because all entries of the array were set to 0, even when ten is volatile, because for every valid value of that it must return 0). Beyond that, some comments: 1) I've disabled deep-stack-uaf-1.C for -flto, because with lto the symbolized function names aren't actually printed as the C++ mangled names, but as plain free (all of them). 2) In large-func-test-1.C, I had to stop matching the backtrace after _Znw[jm], because libasan is using the fast but inaccurate backtrace, and while the tests can be easily tweaked to compile with -fno-omit-frame-pointer, we definitely can't rely on libstdc++.so to be built with that option. Most likely it isn't. I repeat that I think that at least for Linux libasan should use the _Unwind* based backtrace at least for the fatal functions (__asan_report* etc.), and perhaps for these malloc wrappers like ::operator new, ::operator new[] and their const std::nothrow_t& variants libasan could intercept them, call malloc and if that returns NULL, call the original corresponding function so that it deals with exceptions, new handler etc. 3) deep-thread-stack-1.C fails for me right now with some libasan assertion, Kostya, can you please look at that? AsanThread *t = asanThreadRegistry().GetCurrent(); CHECK(t); where it failed on the CHECK, because t was NULL. I've skipped the test for now. 4) some regexps needed tweaking to accomodate older versions of addr2line, those that understand DWARF4 somewhat but not fully (and is sometimes being confused by DW_AT_high_pc GCC 4.8 emits, with that we can end up with e.g. in function cc1ebajk.o:0 instead of in function /usr/src/...filename.c:18) and with even older addr2line which gives up on DWARF4 and thus prints just in function ??:0 etc. I've tested this with current binutils addr2line, Fedora 17 addr2line (doesn't handle DW_AT_high_pc yet), and RHEL5 addr2line (doesn't handle DWARF4 at all). Ok for trunk? 2012-12-05 Jakub Jelinek * g++.dg/asan/deep-tail-call-1.C: Whitespace fixes. Don't rely on argc being one. * g++.dg/asan/interception-malloc-test-1.C: Only run on linux. Whitespace fixes. Avoid unnecessary * sizeof(char). * g++.dg/asan/deep-thread-stack-1.C: Add -lpthread to dg-options, skip for now. Whitespace fixes. * g++.dg/asan/deep-stack-uaf-1.C: Skip for -flto. Whitespace fixes. * g++.dg/asan/interception-test-1.C: Whitespace fixes. * g++.dg/asan/interception-failure-test-1.C: Whitespace fixes. Avoid unnecessary * sizeof(char). Remove // CHECK: comment. * g++.dg/asan/default-options-1.C: Whitespace fixes. * g++.dg/asan/symbolize-callback-1.C: Whitespace fixes. Make first __asan_symbolize argument unnamed. Avoid unnecessary * sizeof(char). * g++.dg/asan/large-func-test-1.C: Whitespace fixes. Don't rely on argc being one. Allow both _Znwj and _Znwm as operator new. Ignore everything in the backtrace above operator new. Fix up dg-output regexps. * c-c++-common/asan/null-deref-1.c: Add -fno-omit-frame-pointer and for x86 -mno-omit-leaf-frame-pointer. Fix up dg-output regexps. * c-c++-common/asan/clone-test-1.c: Whitespace fixes. Return non-zero on failures. Avoid pointless PASS dg-output check. * c-c++-common/asan/sanity-check-pure-c-1.c: Fix up dg-output regexps. Avoid unnecessary * sizeof(char). * c-c++-common/asan/heap-overflow-1.c: Fix up dg-output regexps. Don't rely on argc being one. * c-c++-common/asan/sleep-before-dying-1.c: Whitespace fixes. Avoid unnecessary * sizeof(char). * c-c++-common/asan/rlimit-mmap-test-1.c: Whitespace fixes. * c-c++-common/asan/stack-overflow-1.c: Fix up dg-output regexps. * c-c++-common/asan/global-overflow-1.c: Add -fno-builtin-memset. Fix up dg-output regexps. * c-c++-common/asan/strncpy-overflow-1.c: Fix up dg-output regexps. * c-c++-common/asan/memcmp-1.c: Don't rely on argc being one. * c-c++-common/asan/use-after-free-1.c: Fix up dg-output regexps. * c-c++-common/asan/swapcontext-test-1.c: Don't rely on argc being one. * c-c++-common/asan/force-inline-opt0-1.c: Remove dg-skip-if. * c-c++-common/asan/strip-path-prefix-1.c: Whitespace fixes. Avoid unnecessary * sizeof(char). --- gcc/testsuite/g++.dg/asan/deep-tail-call-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/deep-tail-call-1.C 2012-12-05 11:01:48.600443834 +0100 @@ -1,21 +1,22 @@ -// { dg-do run } +// { dg-do run } // { dg-options "-fno-omit-frame-pointer -fno-optimize-sibling-calls" } // { dg-additional-options "-mno-omit-leaf-frame-pointer" { target { i?86-*-* x86_64-*-* } } } -// { dg-shouldfail "asan" } +// { dg-shouldfail "asan" } int global[10]; void __attribute__((noinline)) call4(int i) { global[i+10]++; } void __attribute__((noinline)) call3(int i) { call4(i); } void __attribute__((noinline)) call2(int i) { call3(i); } void __attribute__((noinline)) call1(int i) { call2(i); } -int main(int argc, char **argv) { - call1(argc); +volatile int one = 1; +int main() { + call1(one); return global[0]; } -// { dg-output "AddressSanitizer:? global-buffer-overflow.*(\n|\r\n|\r)" } -// { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*call4\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #1 0x\[0-9a-f\]+ (in \[^\n\r]*call3\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #2 0x\[0-9a-f\]+ (in \[^\n\r]*call2\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #3 0x\[0-9a-f\]+ (in \[^\n\r]*call1\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #4 0x\[0-9a-f\]+ (in \[^\n\r]*main\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output "AddressSanitizer:? global-buffer-overflow.*(\n|\r\n|\r)" } +// { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*call4\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #1 0x\[0-9a-f\]+ (in \[^\n\r]*call3\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #2 0x\[0-9a-f\]+ (in \[^\n\r]*call2\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #3 0x\[0-9a-f\]+ (in \[^\n\r]*call1\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #4 0x\[0-9a-f\]+ (in \[^\n\r]*main\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } --- gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C 2012-12-05 11:02:14.130293308 +0100 @@ -1,8 +1,8 @@ // ASan interceptor can be accessed with __interceptor_ prefix. -// { dg-do run } +// { dg-do run { target *-*-linux* } } // { dg-options "-fno-builtin-free" } -// { dg-shouldfail "asan" } +// { dg-shouldfail "asan" } #include #include @@ -15,10 +15,10 @@ extern "C" void *malloc(size_t size) { } int main() { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char*)malloc(10); free(x); return (int)strtol(x, 0, 10); } -// { dg-output "malloc call.*(\n|\r\n|\r)" } -// { dg-output "\[^\n\r]*heap-use-after-free" } +// { dg-output "malloc call.*(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*heap-use-after-free" } --- gcc/testsuite/g++.dg/asan/deep-thread-stack-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/deep-thread-stack-1.C 2012-12-05 11:45:31.009423658 +0100 @@ -1,4 +1,6 @@ // { dg-do run { target pthread } } +// { dg-skip-if "" { *-*-* } { "*" } { "" } } +// { dg-options "-lpthread" } // { dg-shouldfail "asan" } #include @@ -49,7 +51,7 @@ int main(int argc, char *argv[]) { // { dg-output "previously allocated by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" } // { dg-output "Thread T\\2 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" } // { dg-output "Thread T\\8 created by T0 here:.*(\n|\r\n|\r)" } -// { dg-output "Thread T\\4 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" } +// { dg-output "Thread T\\4 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" } // { dg-output "Thread T\\11 created by T0 here:.*(\n|\r\n|\r)" } // { dg-output "Thread T\\6 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" } // { dg-output "Thread T\\14 created by T0 here:" } --- gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C 2012-12-05 11:01:42.990476536 +0100 @@ -1,10 +1,11 @@ // Check that we can store lots of stack frames if asked to. -// { dg-do run } +// { dg-do run } +// { dg-skip-if "" { *-*-* } { "-flto" } { "" } } // { dg-set-target-env-var ASAN_OPTIONS "malloc_context_size=120:redzone=512" } // { dg-options "-fno-omit-frame-pointer -fno-optimize-sibling-calls" } // { dg-additional-options "-mno-omit-leaf-frame-pointer" { target { i?86-*-* x86_64-*-* } } } -// { dg-shouldfail "asan" } +// { dg-shouldfail "asan" } #include #include @@ -32,7 +33,7 @@ int main() { return x[5]; } -// { dg-output "ERROR: AddressSanitizer:? heap-use-after-free on address.*(\n|\r\n|\r)" } -// { dg-output " #37 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*36|\[(\]).*(\n|\r\n|\r)" } -// { dg-output " #99 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*98|\[(\]).*(\n|\r\n|\r)" } -// { dg-output " #116 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*115|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output "ERROR: AddressSanitizer:? heap-use-after-free on address.*(\n|\r\n|\r)" } +// { dg-output " #37 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*36|\[(\]).*(\n|\r\n|\r)" } +// { dg-output " #99 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*98|\[(\]).*(\n|\r\n|\r)" } +// { dg-output " #116 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*115|\[(\])\[^\n\r]*(\n|\r\n|\r)" } --- gcc/testsuite/g++.dg/asan/interception-test-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/interception-test-1.C 2012-12-05 11:02:18.224268716 +0100 @@ -2,7 +2,7 @@ // { dg-do run } // { dg-options "-fno-builtin-malloc -fno-builtin-free" } -// { dg-shouldfail "asan" } +// { dg-shouldfail "asan" } #include #include @@ -19,5 +19,5 @@ int main() { return (int)strtol(x, 0, 10); } -// { dg-output "my_strtol_interceptor.*(\n|\r\n|\r)" } -// { dg-output "\[^\n\r]*heap-use-after-free" } +// { dg-output "my_strtol_interceptor.*(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*heap-use-after-free" } --- gcc/testsuite/g++.dg/asan/interception-failure-test-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/interception-failure-test-1.C 2012-12-05 11:02:09.739307322 +0100 @@ -1,7 +1,7 @@ // If user provides his own libc functions, ASan doesn't // intercept these functions. -// { dg-do run } +// { dg-do run } // { dg-options "-fno-builtin-malloc -fno-builtin-free" } #include @@ -13,10 +13,9 @@ extern "C" long strtol(const char *nptr, } int main() { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char*)malloc(10); free(x); return (int)strtol(x, 0, 10); - // CHECK: my_strtol_interceptor } -// { dg-output "my_strtol_interceptor" } +// { dg-output "my_strtol_interceptor" } --- gcc/testsuite/g++.dg/asan/default-options-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/default-options-1.C 2012-12-05 11:02:00.510373678 +0100 @@ -1,4 +1,4 @@ -// { dg-do run } +// { dg-do run } const char *kAsanDefaultOptions="verbosity=1 foo=bar"; @@ -12,4 +12,4 @@ int main() { return 0; } -// { dg-output "Using the defaults from __asan_default_options:.* foo=bar.*(\n|\r\n|\r)" } +// { dg-output "Using the defaults from __asan_default_options:.* foo=bar.*(\n|\r\n|\r)" } --- gcc/testsuite/g++.dg/asan/symbolize-callback-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/symbolize-callback-1.C 2012-12-05 11:02:30.314196137 +0100 @@ -1,21 +1,21 @@ -// { dg-do run } -// { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } +// { dg-do run } +// { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } // { dg-options "-fno-builtin-malloc -fno-builtin-free" } -// { dg-shouldfail "asan" } +// { dg-shouldfail "asan" } #include #include extern "C" -bool __asan_symbolize(const void *pc, char *out_buffer, int out_size) { +bool __asan_symbolize(const void *, char *out_buffer, int out_size) { snprintf(out_buffer, out_size, "MySymbolizer"); return true; } int main() { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char*)malloc(10); free(x); return x[5]; } -// { dg-output "MySymbolizer" } +// { dg-output "MySymbolizer" } --- gcc/testsuite/g++.dg/asan/large-func-test-1.C.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/g++.dg/asan/large-func-test-1.C 2012-12-05 12:25:34.064156196 +0100 @@ -1,5 +1,5 @@ -// { dg-do run } -// { dg-shouldfail "asan" } +// { dg-do run } +// { dg-shouldfail "asan" } #include __attribute__((noinline)) @@ -28,20 +28,18 @@ static void LargeFunction(int *x, int ze x[18]++; x[19]++; } - -int main(int argc, char **argv) { +volatile int one = 1; +int main() { int *x = new int[100]; - LargeFunction(x, argc - 1); + LargeFunction(x, one - 1); delete x; } -// { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" } -// { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output "READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*LargeFunction\[^\n\r]*(large-func-test-1.C:18|\[?\]\[?\]:0)|\[(\]).*(\n|\r\n|\r)" } -// { dg-output "0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" } -// { dg-output "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 (operator new|_Znwm)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #2 0x\[0-9a-f\]+ (in (operator new|_Znam)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #3 0x\[0-9a-f\]+ (in _*main\[^\n\r]*(large-func-test-1.C:33|\[?\]\[?\]:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" } +// { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output "READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*LargeFunction\[^\n\r]*(large-func-test-1.C:18|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } +// { dg-output "0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" } +// { dg-output "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 (operator new|_*_Znw\[mj\])|\[(\])\[^\n\r]*(\n|\r\n|\r)" } --- gcc/testsuite/c-c++-common/asan/null-deref-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/null-deref-1.c 2012-12-05 12:24:26.522557195 +0100 @@ -1,16 +1,23 @@ /* { dg-do run } */ +/* { dg-options "-fno-omit-frame-pointer" } */ +/* { dg-additional-options "-mno-omit-leaf-frame-pointer" { target { i?86-*-* x86_64-*-* } } } */ /* { dg-shouldfail "asan" } */ __attribute__((noinline, noclone)) -static void NullDeref(int *ptr) { +static void +NullDeref(int *ptr) +{ ptr[10]++; } -int main() { + +int main() +{ NullDeref((int*)0); + return 0; } -/* { dg-output "ERROR: AddressSanitizer:? SEGV on unknown address.*" } */ -/* { dg-output "0x\[0-9a-f\]+ .*pc 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "ERROR: AddressSanitizer:? SEGV on unknown address\[^\n\r]*" } */ +/* { dg-output "0x\[0-9a-f\]+ \[^\n\r]*pc 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output "AddressSanitizer can not provide additional info.*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*NullDeref\[^\n\r]*(null-deref-1.c:6|\[?\]\[?\]:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #1 0x\[0-9a-f\]+ (in \[^\n\r]*main\[^\n\r]*(null-deref-1.c:9|\[?\]\[?\]:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*NullDeref\[^\n\r]* (\[^\n\r]*null-deref-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*null-deref-1.c:15|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ --- gcc/testsuite/c-c++-common/asan/clone-test-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/clone-test-1.c 2012-12-05 11:04:12.109599800 +0100 @@ -1,4 +1,4 @@ -/* Regression test for: +/* Regression test for: http://code.google.com/p/address-sanitizer/issues/detail?id=37 */ /* { dg-do run { target { *-*-linux* } } } */ @@ -20,6 +20,8 @@ int Child(void *arg) { _exit(1); /* NoReturn, stack will remain unpoisoned unless we do something. */ } +volatile int zero = 0; + int main(int argc, char **argv) { int i; const int kStackSize = 1 << 20; @@ -31,17 +33,14 @@ int main(int argc, char **argv) { pid_t wait_result = waitpid(clone_pid, &status, __WCLONE); if (wait_result < 0) { perror("waitpid"); - return 0; + return 1; } if (wait_result == clone_pid && WIFEXITED(status)) { /* Make sure the child stack was indeed unpoisoned. */ for (i = 0; i < kStackSize; i++) child_stack[i] = i; - int ret = child_stack[argc - 1]; - printf("PASSED\n"); + int ret = child_stack[zero]; return ret; } - return 0; + return 1; } - -/* { dg-output "PASSED" } */ --- gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c 2012-12-05 12:22:44.517154170 +0100 @@ -4,14 +4,13 @@ #include int main() { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char*)malloc(10); free(x); return x[5]; } /* { dg-output "heap-use-after-free.*(\n|\r\n|\r)" } */ -/* { dg-output " #0 \[^\n\r]*free\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #1 \[^\n\r]*(in main\[^\n\r]*(sanity-check-pure-c-1.c:8|\[?\]\[?\]:0)|\[(\]).*(\n|\r\n|\r)" } */ -/* { dg-output " #0 \[^\n\r]*(interceptor_|)malloc\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #1 \[^\n\r]*(in main\[^\n\r]*(sanity-check-pure-c-1.c:7|\[?\]\[?\]:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ - +/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #1 \[^\n\r]*(in _*main (\[^\n\r]*sanity-check-pure-c-1.c:8|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #1 \[^\n\r]*(in _*main (\[^\n\r]*sanity-check-pure-c-1.c:7|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ --- gcc/testsuite/c-c++-common/asan/heap-overflow-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/heap-overflow-1.c 2012-12-05 12:22:39.632181308 +0100 @@ -4,18 +4,18 @@ #include #include +volatile int ten = 10; int main(int argc, char **argv) { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char*)malloc(10); memset(x, 0, 10); - int res = x[argc * 10]; /* BOOOM */ + int res = x[ten]; /* BOOOM */ free(x); return res; } /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main .*(heap-overflow-1.c:10|\[?\]\[?\]:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:11|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ /* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of 10-byte region\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in .*malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main .*(heap-overflow-1.c:8|\[?\]\[?\]:0)|\[(\])\[^\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]*heap-overflow-1.c:9|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ --- gcc/testsuite/c-c++-common/asan/sleep-before-dying-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/sleep-before-dying-1.c 2012-12-04 20:41:31.127621371 +0100 @@ -1,12 +1,12 @@ /* { dg-do run } */ /* { dg-set-target-env-var ASAN_OPTIONS "sleep_before_dying=1" } */ -/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */ /* { dg-options "-fno-builtin-malloc -fno-builtin-free" } */ /* { dg-shouldfail "asan" } */ #include int main() { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char*)malloc(10); free(x); return x[5]; } --- gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c 2012-12-04 20:41:14.637703428 +0100 @@ -1,7 +1,7 @@ /* Check that we properly report mmap failure. */ /* { dg-do run { target setrlimit } } */ -/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ /* { dg-shouldfail "asan" } */ #include --- gcc/testsuite/c-c++-common/asan/stack-overflow-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/stack-overflow-1.c 2012-12-05 12:22:46.368145570 +0100 @@ -14,5 +14,5 @@ int main() { } /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main \[^\n\r]*(stack-overflow-1.c:12|\[?\]\[?\]:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*stack-overflow-1.c:12|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ /* { dg-output "Address 0x\[0-9a-f\]+ is\[^\n\r]*frame
" } */ --- gcc/testsuite/c-c++-common/asan/global-overflow-1.c.jj 2012-12-05 09:02:25.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/global-overflow-1.c 2012-12-05 12:22:35.517210015 +0100 @@ -1,4 +1,5 @@ /* { dg-do run } */ +/* { dg-options "-fno-builtin-memset" } */ /* { dg-shouldfail "asan" } */ #include @@ -17,6 +18,6 @@ int main() { } /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main .*global-overflow.cc:14|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of global variable.*(\n|\r\n|\r)" } */ -/* { dg-output ".*YYY.* of size 10.*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*global-overflow-1.c:15|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of global variable" } */ +/* { dg-output ".*YYY\[^\n\r]* of size 10\[^\n\r]*(\n|\r\n|\r)" } */ --- gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c 2012-12-05 12:23:11.423993530 +0100 @@ -14,10 +14,8 @@ int main(int argc, char **argv) { /* { dg-output "WRITE of size 1 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|\[?]\[?]:0)|\[(\]).*(\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 "0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output "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|\[?]\[?]: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)" } */ --- gcc/testsuite/c-c++-common/asan/memcmp-1.c.jj 2012-11-23 16:06:31.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/memcmp-1.c 2012-12-04 20:52:09.840918270 +0100 @@ -4,12 +4,14 @@ #include +volatile int one = 1; + int -main (int argc, char **argv) +main () { - char a1[] = {argc, 2, 3, 4}; - char a2[] = {1, 2*argc, 3, 4}; - int res = memcmp (a1, a2, 5 + argc); + char a1[] = {one, 2, 3, 4}; + char a2[] = {1, 2*one, 3, 4}; + int res = memcmp (a1, a2, 5 + one); return res; } --- gcc/testsuite/c-c++-common/asan/use-after-free-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/use-after-free-1.c 2012-12-05 12:23:31.213889677 +0100 @@ -12,11 +12,11 @@ int main() { /* { dg-output "ERROR: AddressSanitizer:? heap-use-after-free on address\[^\n\r]*" } */ /* { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main \[^\n\r]*(use-after-free-1.c:9|\[?]\[?]:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:9|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ /* { dg-output "0x\[0-9a-f\]+ is located 5 bytes inside of 10-byte region .0x\[0-9a-f\]+,0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output "freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #1 0x\[0-9a-f\]+ (in \[^\n\r]*main \[^\n\r]*(use-after-free-1.c:8|\[?]\[?]:0)|\[(\]).*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:8|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */ /* { dg-output "previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output " #1 0x\[0-9a-f\]+ (in \[^\n\r]*main \[^\n\r]*(use-after-free-1.c:7|\[?]\[?]:0)|\[(\])\[^\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]*use-after-free-1.c:7|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ --- gcc/testsuite/c-c++-common/asan/swapcontext-test-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/swapcontext-test-1.c 2012-12-04 20:52:58.324638245 +0100 @@ -47,11 +47,13 @@ int Run(int arg, int mode) { return child_stack[arg]; } +volatile int zero = 0; + int main(int argc, char **argv) { int ret = 0; - ret += Run(argc - 1, 0); + ret += Run(zero, 0); printf("Test1 passed\n"); - ret += Run(argc - 1, 1); + ret += Run(zero, 1); printf("Test2 passed\n"); return ret; } --- gcc/testsuite/c-c++-common/asan/force-inline-opt0-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/force-inline-opt0-1.c 2012-12-04 20:40:31.310940931 +0100 @@ -2,7 +2,6 @@ (before and after inlining) */ /* { dg-do compile } */ -/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O1" } } */ /* { dg-final { scan-assembler-not "__asan_report_load" } } */ __attribute__((always_inline)) --- gcc/testsuite/c-c++-common/asan/strip-path-prefix-1.c.jj 2012-12-04 20:24:10.000000000 +0100 +++ gcc/testsuite/c-c++-common/asan/strip-path-prefix-1.c 2012-12-05 11:04:00.219677616 +0100 @@ -1,12 +1,12 @@ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */ /* { dg-set-target-env-var ASAN_OPTIONS "strip_path_prefix='/'" } */ -/* { dg-options "-fno-builtin-malloc -fno-builtin-free" } */ +/* { dg-options "-fno-builtin-malloc -fno-builtin-free" } */ /* { dg-shouldfail "asan" } */ #include int main() { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char*)malloc(10); free(x); return x[5]; } Jakub