[PATCH] D18431: [tsan] Use direct syscalls for internal_mmap and internal_munmap on OS X

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 04:55:39 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL264259: [tsan] Use direct syscalls for internal_mmap and internal_munmap on OS X (authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D18431?vs=51518&id=51537#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18431

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
  compiler-rt/trunk/test/tsan/Darwin/malloc-stack-logging.cc

Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
@@ -82,15 +82,20 @@
 
 #include "sanitizer_syscall_generic.inc"
 
+// Direct syscalls, don't call libmalloc hooks.
+extern "C" void *__mmap(void *addr, size_t len, int prot, int flags, int fildes,
+                        off_t off);
+extern "C" int __munmap(void *, size_t);
+
 // ---------------------- sanitizer_libc.h
 uptr internal_mmap(void *addr, size_t length, int prot, int flags,
                    int fd, u64 offset) {
   if (fd == -1) fd = VM_MAKE_TAG(VM_MEMORY_ANALYSIS_TOOL);
-  return (uptr)mmap(addr, length, prot, flags, fd, offset);
+  return (uptr)__mmap(addr, length, prot, flags, fd, offset);
 }
 
 uptr internal_munmap(void *addr, uptr length) {
-  return munmap(addr, length);
+  return __munmap(addr, length);
 }
 
 int internal_mprotect(void *addr, uptr length, int prot) {
Index: compiler-rt/trunk/test/tsan/Darwin/malloc-stack-logging.cc
===================================================================
--- compiler-rt/trunk/test/tsan/Darwin/malloc-stack-logging.cc
+++ compiler-rt/trunk/test/tsan/Darwin/malloc-stack-logging.cc
@@ -0,0 +1,19 @@
+// RUN: %clangxx_tsan -O1 %s -o %t
+// RUN: MallocStackLogging=1 %run %t 2>&1 | FileCheck %s
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+void *foo(void *p) {
+    return NULL;
+}
+
+int main() {
+    pthread_t t;
+    pthread_create(&t, NULL, foo, NULL);
+    pthread_join(t, NULL);
+    fprintf(stderr, "Done.\n");
+    return 0;
+}
+
+// CHECK: Done.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18431.51537.patch
Type: text/x-patch
Size: 1705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160324/4803d48d/attachment.bin>


More information about the llvm-commits mailing list