[PATCH] D10944: [asan] Fix an OS X startup crash when an empty section is present

Kuba Brecka kuba.brecka at gmail.com
Mon Jul 6 09:48:59 PDT 2015



Second take on the fix.


http://reviews.llvm.org/D10944

Files:
  lib/sanitizer_common/sanitizer_posix.cc
  test/asan/TestCases/Darwin/empty-section.cc

Index: lib/sanitizer_common/sanitizer_posix.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix.cc
+++ lib/sanitizer_common/sanitizer_posix.cc
@@ -270,6 +270,7 @@
   while (proc_maps.Next(&start, &end,
                         /*offset*/0, /*filename*/0, /*filename_size*/0,
                         /*protection*/0)) {
+    if (start == end) continue;  // Empty range.
     CHECK_NE(0, end);
     if (!IntervalsAreSeparate(start, end - 1, range_start, range_end))
       return false;
Index: test/asan/TestCases/Darwin/empty-section.cc
===================================================================
--- test/asan/TestCases/Darwin/empty-section.cc
+++ test/asan/TestCases/Darwin/empty-section.cc
@@ -0,0 +1,12 @@
+// Regression test with an empty (length = 0) custom section.
+
+// RUN: %clangxx_asan -g -O0 %s -c -o %t.o
+// RUN: %clangxx_asan -g -O0 %t.o -o %t -sectcreate mysegment mysection /dev/null
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+
+int main() {
+  printf("Hello, world!\n");
+  // CHECK: Hello, world!
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10944.29101.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150706/2ae97340/attachment.bin>


More information about the llvm-commits mailing list