[PATCH] D144830: [asan darwin] Allow clients to implement `__sanitizer_report_error_summary`

Dave MacLachlan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 26 10:16:31 PST 2023


dmaclach created this revision.
dmaclach added a reviewer: yln.
dmaclach added a project: Sanitizers.
Herald added a subscriber: Enna1.
Herald added a project: All.
dmaclach requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

`__sanitizer_report_error_summary` is declared `llvm/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h` as being able to be overridden by the client. On darwin the sanitizer runtime uses this symbol to find references to the sanitizer libraries, so if you override it you end up with the error `=ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:` at launch time.

Replace uses of `__sanitizer_report_error_summary` for finding the sanitizer libraries with `++sanitizer_print_stack_trace` which we do not support overriding by clients.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144830

Files:
  b/llvm/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp


Index: b/llvm/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
===================================================================
--- b/llvm/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/llvm/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -987,9 +987,11 @@
   // Verify that interceptors really work.  We'll use dlsym to locate
   // "puts", if interceptors are working, it should really point to
   // "wrap_puts" within our own dylib.
+  // "__sanitizer_print_stack_trace" is an exported function that we do
+  // not support clients implementing.
   Dl_info info_puts, info_runtime;
   RAW_CHECK(dladdr(dlsym(RTLD_DEFAULT, "puts"), &info_puts));
-  RAW_CHECK(dladdr((void *)__sanitizer_report_error_summary, &info_runtime));
+  RAW_CHECK(dladdr((void *)__sanitizer_print_stack_trace, &info_runtime));
   if (internal_strcmp(info_puts.dli_fname, info_runtime.dli_fname) != 0) {
     Report(
         "ERROR: Interceptors are not working. This may be because %s is "
@@ -1039,7 +1041,7 @@
     return;
 
   Dl_info info;
-  RAW_CHECK(dladdr((void *)__sanitizer_report_error_summary, &info));
+  RAW_CHECK(dladdr((void *)__sanitizer_print_stack_trace, &info));
   const char *dylib_name = StripModuleName(info.dli_fname);
   bool lib_is_in_env = internal_strstr(dyld_insert_libraries, dylib_name);
   if (!lib_is_in_env)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144830.500599.patch
Type: text/x-patch
Size: 1381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230226/3761c492/attachment.bin>


More information about the llvm-commits mailing list