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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tools-llvm-exegesis

Author: Aiden Grossman (boomanaiden154)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/74144.diff


1 Files Affected:

- (modified) llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp (+14) 


``````````diff
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();
 

``````````

</details>


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


More information about the llvm-commits mailing list