forked from OSchip/llvm-project
AddressSanitizer: Convert templates for output tests to FileCheck format and move them inside sources
llvm-svn: 150375
This commit is contained in:
parent
b25d0d2318
commit
92a0b806a6
|
@ -29,5 +29,6 @@ int main(int argc, char **argv) {
|
|||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("PASSED\n");
|
||||
// CHECK: PASSED
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
PASSED
|
|
@ -1,12 +1,14 @@
|
|||
// CHECK: AddressSanitizer global-buffer-overflow
|
||||
int global[10];
|
||||
__attribute__((noinline))
|
||||
void call4(int i) { global[i+10]++; }
|
||||
__attribute__((noinline))
|
||||
void call3(int i) { call4(i); }
|
||||
__attribute__((noinline))
|
||||
void call2(int i) { call3(i); }
|
||||
__attribute__((noinline))
|
||||
void call1(int i) { call2(i); }
|
||||
// CHECK: {{#0.*call4}}
|
||||
void __attribute__((noinline)) call4(int i) { global[i+10]++; }
|
||||
// CHECK: {{#1.*call3}}
|
||||
void __attribute__((noinline)) call3(int i) { call4(i); }
|
||||
// CHECK: {{#2.*call2}}
|
||||
void __attribute__((noinline)) call2(int i) { call3(i); }
|
||||
// CHECK: {{#3.*call1}}
|
||||
void __attribute__((noinline)) call1(int i) { call2(i); }
|
||||
// CHECK: {{#4.*main}}
|
||||
int main(int argc, char **argv) {
|
||||
call1(argc);
|
||||
return global[0];
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
AddressSanitizer global-buffer-overflow
|
||||
#0.*call4
|
||||
#1.*call3
|
||||
#2.*call2
|
||||
#3.*call1
|
||||
#4.*main
|
|
@ -69,5 +69,6 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
addr[1] = 2; // BOOM (if the bug is not fixed).
|
||||
printf("PASS\n");
|
||||
// CHECK: PASS
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
PASS
|
|
@ -7,6 +7,9 @@ int main(int argc, char **argv) {
|
|||
memset(YYY, 0, 10);
|
||||
memset(ZZZ, 0, 10);
|
||||
int res = YYY[argc * 10]; // BOOOM
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*global-overflow.cc:9}}
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of global variable .*YYY.* of size 10}}
|
||||
res += XXX[argc] + ZZZ[argc];
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
READ of size 1 at 0x.* thread T0
|
||||
#0 0x.* in main .*global-overflow.cc:9
|
||||
0x.* is located 0 bytes to the right of global variable .*YYY.* of size 10
|
|
@ -7,3 +7,19 @@ int main(int argc, char **argv) {
|
|||
free(x);
|
||||
return res;
|
||||
}
|
||||
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*heap-overflow.cc:6}}
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in malloc}}
|
||||
// CHECK: {{ #1 0x.* in main .*heap-overflow.cc:[45]}}
|
||||
|
||||
// Darwin: {{READ of size 1 at 0x.* thread T0}}
|
||||
// Darwin: {{ #0 0x.* in main .*heap-overflow.cc:6}}
|
||||
// Darwin: {{0x.* is located 0 bytes to the right of 10-byte region}}
|
||||
// Darwin: {{allocated by thread T0 here:}}
|
||||
// Darwin: {{ #0 0x.* in .*mz_malloc.*}}
|
||||
// Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
|
||||
// Darwin: {{ #2 0x.* in malloc.*}}
|
||||
// Darwin: {{ #3 0x.* in main heap-overflow.cc:[45]}}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
READ of size 1 at 0x.* thread T0
|
||||
#0 0x.* in main .*heap-overflow.cc:6
|
||||
0x.* is located 0 bytes to the right of 10-byte region
|
||||
allocated by thread T0 here:
|
||||
#0 0x.* in malloc
|
||||
#1 0x.* in main .*heap-overflow.cc:[45]
|
|
@ -1,8 +0,0 @@
|
|||
READ of size 1 at 0x.* thread T0
|
||||
#0 0x.* in main .*heap-overflow.cc:6
|
||||
0x.* is located 0 bytes to the right of 10-byte region
|
||||
allocated by thread T0 here:
|
||||
#0 0x.* in .*mz_malloc.*
|
||||
#1 0x.* in malloc_zone_malloc.*
|
||||
#2 0x.* in malloc.*
|
||||
#3 0x.* in main heap-overflow.cc:[45]
|
|
@ -31,3 +31,12 @@ int main(int argc, char **argv) {
|
|||
LargeFunction(x, argc - 1);
|
||||
delete x;
|
||||
}
|
||||
|
||||
// CHECK: {{.*ERROR: AddressSanitizer heap-buffer-overflow on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
|
||||
// CHECK: {{READ of size 4 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in LargeFunction .*large_func_test.cc:15}}
|
||||
// CHECK: {{ #1 0x.* in main .*large_func_test.cc:3[012]}}
|
||||
// CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in operator new.*}}
|
||||
// CHECK: {{ #1 0x.* in main .*large_func_test.cc:30}}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
.*ERROR: AddressSanitizer heap-buffer-overflow on address 0x.* at pc 0x.* bp 0x.* sp 0x.*
|
||||
READ of size 4 at 0x.* thread T0
|
||||
#0 0x.* in LargeFunction .*large_func_test.cc:15
|
||||
#1 0x.* in main .*large_func_test.cc:3[012]
|
||||
0x.* is located 44 bytes to the right of 400-byte region
|
||||
allocated by thread T0 here:
|
||||
#0 0x.* in operator new.*
|
||||
#1 0x.* in main .*large_func_test.cc:30
|
|
@ -5,3 +5,14 @@ static void NullDeref(int *ptr) {
|
|||
int main() {
|
||||
NullDeref((int*)0);
|
||||
}
|
||||
|
||||
// CHECK: {{.*ERROR: AddressSanitizer crashed on unknown address 0x0*00028 .*pc 0x.*}}
|
||||
// CHECK: {{AddressSanitizer can not provide additional info. ABORTING}}
|
||||
// CHECK: {{ #0 0x.* in NullDeref.*null_deref.cc:3}}
|
||||
// CHECK: {{ #1 0x.* in main.*null_deref.cc:[67]}}
|
||||
|
||||
// Darwin: {{.*ERROR: AddressSanitizer crashed on unknown address 0x0*00028 .*pc 0x.*}}
|
||||
// Darwin: {{AddressSanitizer can not provide additional info. ABORTING}}
|
||||
// atos cannot resolve the file:line info for frame 0 on the O1 level
|
||||
// Darwin: {{ #0 0x.* in NullDeref.*}}
|
||||
// Darwin: {{ #1 0x.* in main.*null_deref.cc:[67]}}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
.*ERROR: AddressSanitizer crashed on unknown address 0x0*00028 .*pc 0x.*
|
||||
AddressSanitizer can not provide additional info. ABORTING
|
||||
#0 0x.* in NullDeref.*null_deref.cc:3
|
||||
#1 0x.* in main.*null_deref.cc:[67]
|
|
@ -1,5 +0,0 @@
|
|||
.*ERROR: AddressSanitizer crashed on unknown address 0x0*00028 .*pc 0x.*
|
||||
AddressSanitizer can not provide additional info. ABORTING
|
||||
# atos cannot resolve the file:line info for frame 0 on the O1 level
|
||||
#0 0x.* in NullDeref.*
|
||||
#1 0x.* in main.*null_deref.cc:[67]
|
|
@ -32,6 +32,11 @@ int main(int argc, char *argv[]) {
|
|||
if (!inc) return 1;
|
||||
printf("ok\n");
|
||||
inc(1);
|
||||
inc(-1);
|
||||
inc(-1); // BOOM
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CHECK: {{.*ERROR: AddressSanitizer global-buffer-overflow}}
|
||||
// CHECK: {{READ of size 4 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.*}}
|
||||
// CHECK: {{ #1 0x.* in main .*shared-lib-test.cc:3[567]}}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#.*ERROR: AddressSanitizer global-buffer-overflow on address 0x.* at pc 0x.* bp 0x.* sp 0x.*
|
||||
#READ of size 4 at 0x.* thread T0
|
||||
# #0 0x.* in inc .*shared-lib-test-so.cc:11
|
||||
# #1 0x.* in main .*shared-lib-test.cc:33
|
||||
# #2 0x.* in __libc_start_main.*
|
||||
#0x.* is located 4 bytes to the left of global variable 'GLOB' (.*) of size 40
|
||||
#0x.* is located 52 bytes to the right of global variable 'pad' (.*) of size 40
|
|
@ -5,3 +5,7 @@ int main(int argc, char **argv) {
|
|||
int res = x[argc * 10]; // BOOOM
|
||||
return res;
|
||||
}
|
||||
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*stack-overflow.cc:5}}
|
||||
// CHECK: {{Address 0x.* is .* frame <main>}}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
READ of size 1 at 0x.* thread T0
|
||||
#0 0x.* in main .*stack-overflow.cc:5
|
||||
Address 0x.* is .* frame <main>
|
|
@ -16,6 +16,9 @@ __attribute__((noinline))
|
|||
void Func2(char *x) {
|
||||
fprintf(stderr, "2: %p\n", x);
|
||||
*x = 1;
|
||||
// CHECK: {{WRITE of size 1 .* thread T0}}
|
||||
// CHECK: {{ #0.*Func2.*stack-use-after-return.cc:18}}
|
||||
// CHECK: {{is located in frame <.*Func1.*> of T0's stack}}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
|
@ -1,3 +0,0 @@
|
|||
WRITE of size 1 .* thread T0
|
||||
#0.*Func2.*stack-use-after-return.cc:18
|
||||
is located in frame <.*Func1.*> of T0's stack
|
|
@ -7,3 +7,21 @@ int main(int argc, char **argv) {
|
|||
strncpy(short_buffer, hello, 10); // BOOM
|
||||
return short_buffer[8];
|
||||
}
|
||||
|
||||
// CHECK: {{WRITE of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in strncpy}}
|
||||
// CHECK: {{ #1 0x.* in main .*strncpy-overflow.cc:[78]}}
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in malloc}}
|
||||
// CHECK: {{ #1 0x.* in main .*strncpy-overflow.cc:6}}
|
||||
|
||||
// Darwin: {{WRITE of size 1 at 0x.* thread T0}}
|
||||
// Darwin: {{ #0 0x.* in wrap_strncpy}}
|
||||
// Darwin: {{ #1 0x.* in main .*strncpy-overflow.cc:[78]}}
|
||||
// Darwin: {{0x.* is located 0 bytes to the right of 9-byte region}}
|
||||
// Darwin: {{allocated by thread T0 here:}}
|
||||
// Darwin: {{ #0 0x.* in .*mz_malloc.*}}
|
||||
// Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
|
||||
// Darwin: {{ #2 0x.* in malloc.*}}
|
||||
// Darwin: {{ #3 0x.* in main .*strncpy-overflow.cc:6}}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
WRITE of size 1 at 0x.* thread T0
|
||||
#0 0x.* in strncpy
|
||||
#1 0x.* in main .*strncpy-overflow.cc:[78]
|
||||
0x.* is located 0 bytes to the right of 9-byte region
|
||||
allocated by thread T0 here:
|
||||
#0 0x.* in malloc
|
||||
#1 0x.* in main .*strncpy-overflow.cc:6
|
|
@ -1,9 +0,0 @@
|
|||
WRITE of size 1 at 0x.* thread T0
|
||||
#0 0x.* in wrap_strncpy
|
||||
#1 0x.* in main .*strncpy-overflow.cc:[78]
|
||||
0x.* is located 0 bytes to the right of 9-byte region
|
||||
allocated by thread T0 here:
|
||||
#0 0x.* in .*mz_malloc.*
|
||||
#1 0x.* in malloc_zone_malloc.*
|
||||
#2 0x.* in malloc.*
|
||||
#3 0x.* in main .*strncpy-overflow.cc:6
|
|
@ -39,10 +39,14 @@ check_program a.out $C_TEST.c CHECKSLEEP
|
|||
export ASAN_OPTIONS=""
|
||||
rm ./a.out
|
||||
|
||||
for t in *.tmpl; do
|
||||
for t in *.cc; do
|
||||
for b in 32 64; do
|
||||
for O in 0 1 2 3; do
|
||||
c=`basename $t .tmpl`
|
||||
c=`basename $t .cc`
|
||||
if [[ "$c" == *"-so" ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
c_so=$c-so
|
||||
exe=$c.$b.O$O
|
||||
so=$c.$b.O$O-so.so
|
||||
|
@ -52,14 +56,14 @@ for t in *.tmpl; do
|
|||
$build_command
|
||||
[ -e "$c_so.cc" ] && $CXX $CXXFLAGS -g -m$b -faddress-sanitizer -O$O $c_so.cc -fPIC -shared -o $so
|
||||
# If there's an OS-specific template, use it.
|
||||
# Please minimize the use of OS-specific templates.
|
||||
if [ -e "$t.$OS" ]
|
||||
# Otherwise use default template.
|
||||
if [ `grep -c "$OS" $c.cc` -gt 0 ]
|
||||
then
|
||||
actual_t="$t.$OS"
|
||||
check_prefix="$OS"
|
||||
else
|
||||
actual_t="$t"
|
||||
check_prefix="CHECK"
|
||||
fi
|
||||
./$exe 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt | ./match_output.py $actual_t
|
||||
check_program $exe $c.cc $check_prefix
|
||||
rm ./$exe
|
||||
[ -e "$so" ] && rm ./$so
|
||||
done
|
||||
|
|
|
@ -4,3 +4,29 @@ int main() {
|
|||
free(x);
|
||||
return x[5];
|
||||
}
|
||||
|
||||
// CHECK: {{.*ERROR: AddressSanitizer heap-use-after-free on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*use-after-free.cc:5}}
|
||||
// CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
|
||||
// CHECK: {{freed by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in free}}
|
||||
// CHECK: {{ #1 0x.* in main .*use-after-free.cc:[45]}}
|
||||
// CHECK: {{previously allocated by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in malloc}}
|
||||
// CHECK: {{ #1 0x.* in main .*use-after-free.cc:3}}
|
||||
|
||||
// Darwin: {{.*ERROR: AddressSanitizer heap-use-after-free on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
|
||||
// Darwin: {{READ of size 1 at 0x.* thread T0}}
|
||||
// Darwin: {{ #0 0x.* in main .*use-after-free.cc:5}}
|
||||
// Darwin: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
|
||||
// Darwin: {{freed by thread T0 here:}}
|
||||
// Darwin: {{ #0 0x.* in .*mz_free.*}}
|
||||
// We override free() on Darwin, thus no malloc_zone_free
|
||||
// Darwin: {{ #1 0x.* in free}}
|
||||
// Darwin: {{ #2 0x.* in main .*use-after-free.cc:[45]}}
|
||||
// Darwin: {{previously allocated by thread T0 here:}}
|
||||
// Darwin: {{ #0 0x.* in .*mz_malloc.*}}
|
||||
// Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
|
||||
// Darwin: {{ #2 0x.* in malloc.*}}
|
||||
// Darwin: {{ #3 0x.* in main .*use-after-free.cc:3}}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
.*ERROR: AddressSanitizer heap-use-after-free on address 0x.* at pc 0x.* bp 0x.* sp 0x.*
|
||||
READ of size 1 at 0x.* thread T0
|
||||
#0 0x.* in main .*use-after-free.cc:5
|
||||
0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*
|
||||
freed by thread T0 here:
|
||||
#0 0x.* in free
|
||||
#1 0x.* in main .*use-after-free.cc:[45]
|
||||
previously allocated by thread T0 here:
|
||||
#0 0x.* in malloc
|
||||
#1 0x.* in main .*use-after-free.cc:3
|
|
@ -1,14 +0,0 @@
|
|||
.*ERROR: AddressSanitizer heap-use-after-free on address 0x.* at pc 0x.* bp 0x.* sp 0x.*
|
||||
READ of size 1 at 0x.* thread T0
|
||||
#0 0x.* in main .*use-after-free.cc:5
|
||||
0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*
|
||||
freed by thread T0 here:
|
||||
#0 0x.* in .*mz_free.*
|
||||
# We override free() on Darwin, thus no malloc_zone_free
|
||||
#1 0x.* in free
|
||||
#2 0x.* in main .*use-after-free.cc:[45]
|
||||
previously allocated by thread T0 here:
|
||||
#0 0x.* in .*mz_malloc.*
|
||||
#1 0x.* in malloc_zone_malloc.*
|
||||
#2 0x.* in malloc.*
|
||||
#3 0x.* in main .*use-after-free.cc:3
|
Loading…
Reference in New Issue