[PATCH] D24773: [asan] Fix GlobalAddressDescription::Print()

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rL282012: [asan] Fix GlobalAddressDescription::Print() (authored by filcab).

Changed prior to commit:
  https://reviews.llvm.org/D24773?vs=71958&id=71979#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24773

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

Index: compiler-rt/trunk/lib/asan/asan_descriptions.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_descriptions.cc
+++ compiler-rt/trunk/lib/asan/asan_descriptions.cc
@@ -323,7 +323,8 @@
 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();
Index: compiler-rt/trunk/test/asan/TestCases/global-address.cpp
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/global-address.cpp
+++ compiler-rt/trunk/test/asan/TestCases/global-address.cpp
@@ -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);
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24773.71979.patch
Type: text/x-patch
Size: 1429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160920/1dc15ac7/attachment.bin>


More information about the llvm-commits mailing list