[compiler-rt] r292998 - [asan] fix __sanitizer_cov_with_check to get the correct caller PC. Before this fix the code relied on the fact that the other function (__sanitizer_cov) is inlined. This was true with clang builds on x86, but not true with gcc builds on x86 and on PPC. This caused bot redness after r292862

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 17:14:24 PST 2017


Author: kcc
Date: Tue Jan 24 19:14:24 2017
New Revision: 292998

URL: http://llvm.org/viewvc/llvm-project?rev=292998&view=rev
Log:
[asan] fix __sanitizer_cov_with_check to get the correct caller PC. Before this fix the code relied on the fact that the other function (__sanitizer_cov) is inlined. This was true with clang builds on x86, but not true with gcc builds on x86 and on PPC. This caused bot redness after r292862

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/coverage-direct.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc?rev=292998&r1=292997&r2=292998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc Tue Jan 24 19:14:24 2017
@@ -939,7 +939,8 @@ SANITIZER_INTERFACE_ATTRIBUTE void __san
   atomic_uint32_t *atomic_guard = reinterpret_cast<atomic_uint32_t*>(guard);
   if (static_cast<s32>(
           __sanitizer::atomic_load(atomic_guard, memory_order_relaxed)) < 0)
-    __sanitizer_cov(guard);
+  coverage_data.Add(StackTrace::GetPreviousInstructionPc(GET_CALLER_PC()),
+                    guard);
 }
 SANITIZER_INTERFACE_ATTRIBUTE void
 __sanitizer_cov_indir_call16(uptr callee, uptr callee_cache16[]) {

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/coverage-direct.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/coverage-direct.cc?rev=292998&r1=292997&r2=292998&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/coverage-direct.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/coverage-direct.cc Tue Jan 24 19:14:24 2017
@@ -35,7 +35,7 @@
 // RUN: %sancov print *.sancov >out.txt
 // RUN: cd ../..
 
-// TEMPORARILY_DISABLED: diff -u coverage-direct/normal/out.txt coverage-direct/direct/out.txt
+// RUN: diff -u coverage-direct/normal/out.txt coverage-direct/direct/out.txt
 
 
 // RUN: %clangxx_asan -fsanitize-coverage=edge -DSHARED %s -shared -o %dynamiclib -fPIC
@@ -54,7 +54,7 @@
 // RUN: %sancov print *.sancov >out.txt
 // RUN: cd ../..
 
-// TEMPORARILY_DISABLED: diff -u coverage-direct/normal/out.txt coverage-direct/direct/out.txt
+// RUN: diff -u coverage-direct/normal/out.txt coverage-direct/direct/out.txt
 
 // XFAIL: android
 




More information about the llvm-commits mailing list