[compiler-rt] r279661 - [ubsan] fix the test to me more resistent against changes in the sanitizer allocator

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 14:03:29 PDT 2016


Author: kcc
Date: Wed Aug 24 16:03:28 2016
New Revision: 279661

URL: http://llvm.org/viewvc/llvm-project?rev=279661&view=rev
Log:
[ubsan] fix the test to me more resistent against changes in the sanitizer allocator 

Modified:
    compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp

Modified: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp?rev=279661&r1=279660&r2=279661&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp Wed Aug 24 16:03:28 2016
@@ -50,6 +50,8 @@ struct V : S {};
 // Make p global so that lsan does not complain.
 T *p = 0;
 
+volatile void *sink1, *sink2;
+
 int access_p(T *p, char type);
 
 int main(int argc, char **argv) {
@@ -74,6 +76,11 @@ int main(int argc, char **argv) {
 
   char Buffer[sizeof(U)] = {};
   char TStorage[sizeof(T)];
+  // Allocate two dummy objects so that the real object
+  // is not on the boundary of mapped memory. Otherwise ubsan
+  // will not be able to describe the vptr in detail.
+  sink1 = new T;
+  sink2 = new U;
   switch (argv[1][1]) {
   case '0':
     p = reinterpret_cast<T*>(Buffer);




More information about the llvm-commits mailing list