summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Ostapenko <m.ostapenko@samsung.com>2016-08-04 11:27:22 +0300
committerMaxim Ostapenko <m.ostapenko@samsung.com>2016-08-04 11:30:14 +0300
commita3685d08d683a65a49607f198dc7bafa17059162 (patch)
tree16a94c58dc06178af447efa6b579fb252239e2dd
parentaa5d38a3a03ce6704de2b61bf2bf16a8dcd0924a (diff)
downloadlinaro-gcc-a3685d08d683a65a49607f198dc7bafa17059162.tar.gz
linaro-gcc-a3685d08d683a65a49607f198dc7bafa17059162.tar.bz2
linaro-gcc-a3685d08d683a65a49607f198dc7bafa17059162.zip
Some ASan tests fail due to: 1) Unable to unwind malloc trace. 2) Return invalid code due to hant_on_error=false enabled by default. Let's fix this. Change-Id: I634c5bff0e21a693a4168eaa12f443cee114a83e Signed-off-by: Maxim Ostapenko <m.ostapenko@samsung.com>
-rw-r--r--gcc/testsuite/c-c++-common/asan/heap-overflow-1.c9
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr61530.c4
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr70541.c19
-rw-r--r--gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c18
-rw-r--r--gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c20
-rw-r--r--gcc/testsuite/c-c++-common/asan/use-after-free-1.c20
-rw-r--r--gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C2
-rw-r--r--gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C2
-rw-r--r--gcc/testsuite/g++.dg/asan/interception-test-1.C4
9 files changed, 79 insertions, 19 deletions
diff --git a/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c b/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c
index 0377a6cf468..d6ad80359c3 100644
--- a/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c
+++ b/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c
@@ -10,6 +10,11 @@ void *memset (void *, int, __SIZE_TYPE__);
void *malloc (__SIZE_TYPE__);
void free (void *);
+const char *
+__asan_default_options () {
+ return "fast_unwind_on_malloc=false";
+}
+
#ifdef __cplusplus
}
#endif
@@ -24,8 +29,8 @@ int main(int argc, char **argv) {
}
/* { 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 (\[^\n\r]*heap-overflow-1.c:21|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
+/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*heap-overflow-1.c:26|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of 10-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_|wrap_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*heap-overflow-1.c:19|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*heap-overflow-1.c:24|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/c-c++-common/asan/pr61530.c b/gcc/testsuite/c-c++-common/asan/pr61530.c
index e306a71be93..445bca40e13 100644
--- a/gcc/testsuite/c-c++-common/asan/pr61530.c
+++ b/gcc/testsuite/c-c++-common/asan/pr61530.c
@@ -3,7 +3,7 @@
__attribute__((noinline,noclone)) void
foo (char *a, char *b) {
- a[0] = b[0] = 0;
+ a[0] = b[0] = 1;
__builtin_memcpy(a, b, 4);
}
@@ -11,7 +11,7 @@ int
main () {
char a, b;
foo (&a, &b);
- return 0;
+ return a;
}
/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */
diff --git a/gcc/testsuite/c-c++-common/asan/pr70541.c b/gcc/testsuite/c-c++-common/asan/pr70541.c
index b2a4bd5e079..464a1f16314 100644
--- a/gcc/testsuite/c-c++-common/asan/pr70541.c
+++ b/gcc/testsuite/c-c++-common/asan/pr70541.c
@@ -6,6 +6,19 @@
#include <stdio.h>
#include <stdlib.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char *
+__asan_default_options () {
+ return "fast_unwind_on_malloc=false";
+}
+
+#ifdef __cplusplus
+}
+#endif
+
struct Simple {
int value;
};
@@ -25,10 +38,10 @@ 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 "\[^\n\r]*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 _*main (\[^\n\r]*pr70541.c:21|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
+/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:34|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:20|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
+/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:33|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:18|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:31|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c b/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c
index 219fcf8ac32..aa044a5a3e2 100644
--- a/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c
+++ b/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c
@@ -3,6 +3,20 @@
/* { dg-shouldfail "asan" } */
#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char *
+__asan_default_options () {
+ return "fast_unwind_on_malloc=false";
+}
+
+#ifdef __cplusplus
+}
+#endif
+
int main() {
char *x = (char*)malloc(10);
free(x);
@@ -11,6 +25,6 @@ int main() {
/* { dg-output "heap-use-after-free.*(\n|\r\n|\r)" } */
/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|wrap_)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 " #1 \[^\n\r]*(in _*main (\[^\n\r]*sanity-check-pure-c-1.c:22|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|wrap_)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)" } */
+/* { dg-output " #1 \[^\n\r]*(in _*main (\[^\n\r]*sanity-check-pure-c-1.c:21|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
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 45759ae8e95..333035a81c2 100644
--- a/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
+++ b/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
@@ -4,18 +4,32 @@
#include <string.h>
#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char *
+__asan_default_options () {
+ return "fast_unwind_on_malloc=false";
+}
+
+#ifdef __cplusplus
+}
+#endif
+
int main(int argc, char **argv) {
char *hello = (char*)malloc(6);
strcpy(hello, "hello");
char *short_buffer = (char*)malloc(9);
strncpy(short_buffer, hello, 10); /* BOOM */
- return short_buffer[8];
+ return short_buffer[0];
}
/* { 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_|wrap_|)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 " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*strncpy-overflow-1.c:25|\[^\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 "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)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:24|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/c-c++-common/asan/use-after-free-1.c b/gcc/testsuite/c-c++-common/asan/use-after-free-1.c
index 75d8f9faa2d..f83bf6d7014 100644
--- a/gcc/testsuite/c-c++-common/asan/use-after-free-1.c
+++ b/gcc/testsuite/c-c++-common/asan/use-after-free-1.c
@@ -3,6 +3,20 @@
/* { dg-shouldfail "asan" } */
#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char *
+__asan_default_options () {
+ return "fast_unwind_on_malloc=false";
+}
+
+#ifdef __cplusplus
+}
+#endif
+
int main() {
char *x = (char*)malloc(10);
free(x);
@@ -12,11 +26,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 "\[^\n\r]*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|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
+/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*use-after-free-1.c:23|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*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 "\[^\n\r]*freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)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 " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*use-after-free-1.c:22|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)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)" } */
+/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*use-after-free-1.c:21|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C b/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C
index 4ae91f7ea52..b1057a81b16 100644
--- a/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C
+++ b/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C
@@ -2,7 +2,7 @@
// { dg-do run }
// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
-// { dg-set-target-env-var ASAN_OPTIONS "malloc_context_size=120:redzone=512" }
+// { dg-set-target-env-var ASAN_OPTIONS "malloc_context_size=120:redzone=512:fast_unwind_on_malloc=false" }
// { 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" }
diff --git a/gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C b/gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C
index e64c184a48a..117d34ae02e 100644
--- a/gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C
+++ b/gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C
@@ -18,7 +18,7 @@ extern "C" void *malloc(size_t size) {
int main() {
char *x = (char*)malloc(10);
free(x);
- return (int)strtol(x, 0, 10);
+ return (int)strtol(x, 0, 10) != 0xdeadbeef;
}
// { dg-output "malloc call.*(\n|\r\n|\r)" }
diff --git a/gcc/testsuite/g++.dg/asan/interception-test-1.C b/gcc/testsuite/g++.dg/asan/interception-test-1.C
index 79248e06df6..57c25db0338 100644
--- a/gcc/testsuite/g++.dg/asan/interception-test-1.C
+++ b/gcc/testsuite/g++.dg/asan/interception-test-1.C
@@ -3,8 +3,8 @@
// { dg-do run }
// { dg-options "-fno-builtin-malloc -fno-builtin-free" }
// { dg-additional-options "-D__NO_INLINE__" { target { *-*-linux-gnu } } }
-// { dg-shouldfail "asan" }
// { dg-skip-if "Darwin uses mac function interposition" { *-*-darwin* } }
+// { dg-shouldfail "asan" }
#include <stdlib.h>
#include <stdio.h>
@@ -18,7 +18,7 @@ extern "C" long strtol(const char *nptr, char **endptr, int base) {
int main() {
char *x = (char*)malloc(10);
free(x);
- return (int)strtol(x, 0, 10);
+ return (int)strtol(x, 0, 10) != 0xdeadbeef;
}
// { dg-output "my_strtol_interceptor.*(\n|\r\n|\r)" }