[PATCH] D48806: [asan] Fix deadlock issue on FreeBSD, caused by use of .preinit_array in rL325240

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 30 18:17:01 PDT 2018


MaskRay updated this revision to Diff 153641.
MaskRay added a comment.

80 columns rule


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D48806

Files:
  lib/sanitizer_common/sanitizer_internal_defs.h


Index: lib/sanitizer_common/sanitizer_internal_defs.h
===================================================================
--- lib/sanitizer_common/sanitizer_internal_defs.h
+++ lib/sanitizer_common/sanitizer_internal_defs.h
@@ -98,11 +98,16 @@
 
 // We can use .preinit_array section on Linux to call sanitizer initialization
 // functions very early in the process startup (unless PIC macro is defined).
+//
+// On FreeBSD, .preinit_array functions are called with rtld_bind_lock writer
+// lock held. It will lead to dead lock if unresolved PLT functions (which helds
+// rtld_bind_lock reader lock) are called inside .preinit_array functions.
+//
 // FIXME: do we have anything like this on Mac?
 #ifndef SANITIZER_CAN_USE_PREINIT_ARRAY
-#if ((SANITIZER_LINUX && !SANITIZER_ANDROID) || \
-  SANITIZER_FREEBSD || SANITIZER_OPENBSD) && !defined(PIC)
-# define SANITIZER_CAN_USE_PREINIT_ARRAY 1
+#if ((SANITIZER_LINUX && !SANITIZER_ANDROID) || SANITIZER_OPENBSD) && \
+    !defined(PIC)
+#define SANITIZER_CAN_USE_PREINIT_ARRAY 1
 // Before Solaris 11.4, .preinit_array is fully supported only with GNU ld.
 // FIXME: Check for those conditions.
 #elif SANITIZER_SOLARIS && !defined(PIC)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48806.153641.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180701/a190bb2a/attachment.bin>


More information about the llvm-commits mailing list