Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 2295a0e

Browse files
committed
[ubsan] -fsanitize=vptr now requires -fsanitize=null, update tests
See: https://bugs.llvm.org/show_bug.cgi?id=33881 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309008 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5764cd9 commit 2295a0e

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

test/ubsan/TestCases/TypeCheck/PR33221.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -frtti -fsanitize=vptr -g %s -O3 -o %t
1+
// RUN: %clangxx -frtti -fsanitize=null,vptr -g %s -O3 -o %t
22
// RUN: %run %t 2>&1 | FileCheck %s
33

44
// REQUIRES: cxxabi

test/ubsan/TestCases/TypeCheck/vptr-corrupted-vtable-itanium.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t
1+
// RUN: %clangxx -frtti -fsanitize=vptr,null -fno-sanitize-recover=vptr,null -g %s -O3 -o %t
22
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-CORRUPTED-VTABLE --strict-whitespace
33

44
// UNSUPPORTED: win32

test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t
1+
// RUN: %clangxx -frtti -fsanitize=null,vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t
22
// RUN: not %run %t 2>&1 | FileCheck %s
33

44
// REQUIRES: cxxabi

test/ubsan/TestCases/TypeCheck/vptr.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t -mllvm -enable-tail-merge=false
1+
// RUN: %clangxx -frtti -fsanitize=null,vptr -fno-sanitize-recover=null,vptr -g %s -O3 -o %t -mllvm -enable-tail-merge=false
22
// RUN: %run %t rT && %run %t mT && %run %t fT && %run %t cT
33
// RUN: %run %t rU && %run %t mU && %run %t fU && %run %t cU
44
// RUN: %run %t rS && %run %t rV && %run %t oV
@@ -9,7 +9,9 @@
99
// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t fV 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN --strict-whitespace
1010
// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t cV 2>&1 | FileCheck %s --check-prefix=CHECK-DOWNCAST --check-prefix=CHECK-%os-DOWNCAST --strict-whitespace
1111
// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t oU 2>&1 | FileCheck %s --check-prefix=CHECK-OFFSET --check-prefix=CHECK-%os-OFFSET --strict-whitespace
12-
// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t m0 2>&1 | FileCheck %s --check-prefix=CHECK-NULL-MEMBER --check-prefix=CHECK-%os-NULL-MEMBER --strict-whitespace
12+
// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t m0 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID-MEMBER --check-prefix=CHECK-%os-NULL-MEMBER --strict-whitespace
13+
// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t m0 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID-MEMBER --check-prefix=CHECK-%os-NULL-MEMBER --strict-whitespace
14+
// RUN: not %run %t nN 2>&1 | FileCheck %s --check-prefix=CHECK-NULL-MEMFUN --strict-whitespace
1315

1416
// RUN: (echo "vptr_check:S"; echo "vptr_check:T"; echo "vptr_check:U") > %t.supp
1517
// RUN: %env_ubsan_opts=suppressions='"%t.supp"' %run %t mS
@@ -99,6 +101,9 @@ int main(int argc, char **argv) {
99101
case 'V':
100102
p = reinterpret_cast<T*>(new U);
101103
break;
104+
case 'N':
105+
p = 0;
106+
break;
102107
}
103108

104109
access_p(p, argv[1][0]);
@@ -134,11 +139,11 @@ int access_p(T *p, char type) {
134139
// CHECK-Linux-MEMBER: #0 {{.*}}access_p{{.*}}vptr.cpp:[[@LINE+1]]
135140
return p->b;
136141

137-
// CHECK-NULL-MEMBER: vptr.cpp:[[@LINE-2]]:15: runtime error: member access within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
138-
// CHECK-NULL-MEMBER-NEXT: [[PTR]]: note: object has invalid vptr
139-
// CHECK-NULL-MEMBER-NEXT: {{^ ?.. .. .. .. ?00 00 00 00 ?00 00 00 00 ?}}
140-
// CHECK-NULL-MEMBER-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}}
141-
// CHECK-NULL-MEMBER-NEXT: {{^ invalid vptr}}
142+
// CHECK-INVALID-MEMBER: vptr.cpp:[[@LINE-2]]:15: runtime error: member access within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
143+
// CHECK-INVALID-MEMBER-NEXT: [[PTR]]: note: object has invalid vptr
144+
// CHECK-INVALID-MEMBER-NEXT: {{^ ?.. .. .. .. ?00 00 00 00 ?00 00 00 00 ?}}
145+
// CHECK-INVALID-MEMBER-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}}
146+
// CHECK-INVALID-MEMBER-NEXT: {{^ invalid vptr}}
142147
// CHECK-Linux-NULL-MEMBER: #0 {{.*}}access_p{{.*}}vptr.cpp:[[@LINE-7]]
143148

144149
case 'f':
@@ -168,6 +173,10 @@ int access_p(T *p, char type) {
168173
// CHECK-Linux-DOWNCAST: #0 {{.*}}access_p{{.*}}vptr.cpp:[[@LINE+1]]
169174
(void)static_cast<T*>(reinterpret_cast<S*>(p));
170175
return 0;
176+
177+
case 'n':
178+
// CHECK-NULL-MEMFUN: vptr.cpp:[[@LINE+1]]:15: runtime error: member call on null pointer of type 'T'
179+
return p->g();
171180
}
172181
return 0;
173182
}

0 commit comments

Comments
 (0)