[PATCH] D65221: [Sanitizer][ASAN][MSAN] Fix infinite recursion on FreeBSD

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 09:32:45 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL367442: [Sanitizer][ASAN][MSAN] Fix infinite recursion on FreeBSD (authored by arichardson, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D65221?vs=212541&id=212604#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65221/new/

https://reviews.llvm.org/D65221

Files:
  compiler-rt/trunk/lib/asan/asan_posix.cc
  compiler-rt/trunk/lib/msan/msan_linux.cc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
  compiler-rt/trunk/test/asan/TestCases/Posix/fread_fwrite.cc
  compiler-rt/trunk/test/asan/TestCases/Posix/tsd_dtor_leak.cc
  compiler-rt/trunk/test/msan/tzset.cc


Index: compiler-rt/trunk/test/msan/tzset.cc
===================================================================
--- compiler-rt/trunk/test/msan/tzset.cc
+++ compiler-rt/trunk/test/msan/tzset.cc
@@ -1,5 +1,4 @@
 // RUN: %clangxx_msan -O0 %s -o %t && %run %t
-// XFAIL: freebsd
 
 #include <stdlib.h>
 #include <string.h>
Index: compiler-rt/trunk/test/asan/TestCases/Posix/fread_fwrite.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/fread_fwrite.cc
+++ compiler-rt/trunk/test/asan/TestCases/Posix/fread_fwrite.cc
@@ -1,9 +1,6 @@
 // RUN: %clangxx_asan -g %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-FWRITE
 // RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK-FREAD
-//
-// On FreeBSD stack overflow error instead
-// XFAIL: freebsd
 
 #include <stdio.h>
 #include <stdlib.h>
Index: compiler-rt/trunk/test/asan/TestCases/Posix/tsd_dtor_leak.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/tsd_dtor_leak.cc
+++ compiler-rt/trunk/test/asan/TestCases/Posix/tsd_dtor_leak.cc
@@ -3,8 +3,6 @@
 // RUN: %clangxx_asan -O1 %s -pthread -o %t
 // RUN: %env_asan_opts=quarantine_size_mb=0 %run %t
 // XFAIL: x86_64-netbsd
-// Assertion fails
-// XFAIL: x86_64-freebsd
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: compiler-rt/trunk/lib/msan/msan_linux.cc
===================================================================
--- compiler-rt/trunk/lib/msan/msan_linux.cc
+++ compiler-rt/trunk/lib/msan/msan_linux.cc
@@ -174,8 +174,8 @@
 
 // ---------------------- TSD ---------------- {{{1
 
-#if SANITIZER_NETBSD || SANITIZER_FREEBSD
-// Thread Static Data cannot be used in early init on NetBSD and FreeBSD.
+#if SANITIZER_NETBSD
+// Thread Static Data cannot be used in early init on NetBSD.
 // Reuse the MSan TSD API for compatibility with existing code
 // with an alternative implementation.
 
Index: compiler-rt/trunk/lib/asan/asan_posix.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc
+++ compiler-rt/trunk/lib/asan/asan_posix.cc
@@ -39,8 +39,8 @@
 
 // ---------------------- TSD ---------------- {{{1
 
-#if SANITIZER_NETBSD || SANITIZER_FREEBSD
-// Thread Static Data cannot be used in early init on NetBSD and FreeBSD.
+#if SANITIZER_NETBSD
+// Thread Static Data cannot be used in early init on NetBSD.
 // Reuse the Asan TSD API for compatibility with existing code
 // with an alternative implementation.
 
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
@@ -779,7 +779,11 @@
 #if SANITIZER_FREEBSD
 int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp,
                           const void *newp, uptr newlen) {
-  return sysctlbyname(sname, oldp, (size_t *)oldlenp, newp, (size_t)newlen);
+  static decltype(sysctlbyname) *real = nullptr;
+  if (!real)
+    real = (decltype(sysctlbyname) *)dlsym(RTLD_NEXT, "sysctlbyname");
+  CHECK(real);
+  return real(sname, oldp, (size_t *)oldlenp, newp, (size_t)newlen);
 }
 #endif
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65221.212604.patch
Type: text/x-patch
Size: 3332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190731/75410f16/attachment.bin>


More information about the llvm-commits mailing list