[PATCH] D30222: [compiler-rt] Prevent symbolizer from starting itself.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 13:17:24 PST 2017


vitalybuka created this revision.
Herald added subscribers: dberris, kubamracek.

If symbolizer was instrumented with sanitizer and crash, it may
try to call itself again causing infinite recursion of crashing processes.


https://reviews.llvm.org/D30222

Files:
  lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc


Index: lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
+++ lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
@@ -385,7 +385,23 @@
   CHECK_NE(path_[0], '\0');
 }
 
+static bool IsSameModule(const char* path) {
+  if (const char* ProcessName = GetProcessName()) {
+    if (const char* SymbolizerName = StripModuleName(path)) {
+      return !internal_strcmp(ProcessName, SymbolizerName);
+    }
+  }
+  return false;
+}
+
 const char *SymbolizerProcess::SendCommand(const char *command) {
+  if (failed_to_start_)
+    return nullptr;
+  if (IsSameModule(path_)) {
+    Report("WARNING: Blocked from starting itself!\n");
+    failed_to_start_ = true;
+    return nullptr;
+  }
   for (; times_restarted_ < kMaxTimesRestarted; times_restarted_++) {
     // Start or restart symbolizer if we failed to send command to it.
     if (const char *res = SendCommandImpl(command))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30222.89271.patch
Type: text/x-patch
Size: 1006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170221/f57392fc/attachment.bin>


More information about the llvm-commits mailing list