[llvm] [llvm-exegesis] Disable core dumps in subprocess (PR #74144)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 13:18:15 PST 2023


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/74144

Core dumps are currently enabled within the llvm-exegesis subprocess executor. This can create a lot of core dumps when going through different snippets that might segfault when experimenting with memory annotations. These core dumps are not really needed as the information about the segfault is reported directly to the user.

>From 9833eaafa91d865501daf1cc7dc478b85839c33c Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Fri, 1 Dec 2023 13:09:22 -0800
Subject: [PATCH] [llvm-exegesis] Disable core dumps in subprocess

Core dumps are currently enabled within the llvm-exegesis subprocess
executor. This can create a lot of core dumps when going through
different snippets that might segfault when experimenting with memory
annotations. These core dumps are not really needed as the information
about the segfault is reported directly to the user.
---
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 85375dec2a44c30..33180d1099c7a87 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -34,6 +34,7 @@
 #endif
 #include <sys/mman.h>
 #include <sys/ptrace.h>
+#include <sys/resource.h>
 #include <sys/socket.h>
 #include <sys/syscall.h>
 #include <sys/wait.h>
@@ -378,8 +379,21 @@ class SubProcessFunctionExecutorImpl
         Twine(strsignal(ChildSignalInfo.si_signo)));
   }
 
+  void disableCoreDumps() const {
+    struct rlimit rlim;
+
+    rlim.rlim_cur = 0;
+    setrlimit(RLIMIT_CORE, &rlim);
+  }
+
   [[noreturn]] void prepareAndRunBenchmark(int Pipe,
                                            const BenchmarkKey &Key) const {
+    // Disable core dumps in the child process as otherwise everytime we
+    // encounter an execution failure like a segmentation fault, we will create
+    // a core dump. We report the information directly rather than require the
+    // user inspect a core dump.
+    disableCoreDumps();
+
     // The following occurs within the benchmarking subprocess
     pid_t ParentPID = getppid();
 



More information about the llvm-commits mailing list