[compiler-rt] r282012 - [asan] Fix GlobalAddressDescription::Print()

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 13:33:18 PDT 2016


Author: filcab
Date: Tue Sep 20 15:33:18 2016
New Revision: 282012

URL: http://llvm.org/viewvc/llvm-project?rev=282012&view=rev
Log:
[asan] Fix GlobalAddressDescription::Print()

Summary: Check bug_type for nullptr before calling internal_strcmp

Reviewers: kcc, vitalybuka, eugenis

Subscribers: kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D24773

Added:
    compiler-rt/trunk/test/asan/TestCases/global-address.cpp
Modified:
    compiler-rt/trunk/lib/asan/asan_descriptions.cc

Modified: compiler-rt/trunk/lib/asan/asan_descriptions.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_descriptions.cc?rev=282012&r1=282011&r2=282012&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_descriptions.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_descriptions.cc Tue Sep 20 15:33:18 2016
@@ -323,7 +323,8 @@ void ShadowAddressDescription::Print() c
 void GlobalAddressDescription::Print(const char *bug_type) const {
   for (int i = 0; i < size; i++) {
     DescribeAddressRelativeToGlobal(addr, access_size, globals[i]);
-    if (0 == internal_strcmp(bug_type, "initialization-order-fiasco") &&
+    if (bug_type &&
+        0 == internal_strcmp(bug_type, "initialization-order-fiasco") &&
         reg_sites[i]) {
       Printf("  registered at:\n");
       StackDepotGet(reg_sites[i]).Print();

Added: compiler-rt/trunk/test/asan/TestCases/global-address.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/global-address.cpp?rev=282012&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/global-address.cpp (added)
+++ compiler-rt/trunk/test/asan/TestCases/global-address.cpp Tue Sep 20 15:33:18 2016
@@ -0,0 +1,12 @@
+// RUN: %clangxx_asan -o %t %s
+// RUN: not %run %t 2>&1 | FileCheck %s
+#include <sanitizer/allocator_interface.h>
+
+int g_i = 42;
+int main() {
+  // CHECK: AddressSanitizer: attempting to call __sanitizer_get_allocated_size() for pointer which is not owned
+  // CHECK-NOT: ASAN:DEADLYSIGNAL
+  // CHECK: SUMMARY: AddressSanitizer: bad-__sanitizer_get_allocated_size
+  // CHECK-NOT: ASAN:DEADLYSIGNAL
+  return (int)__sanitizer_get_allocated_size(&g_i);
+}




More information about the llvm-commits mailing list