[llvm] [llvm-exegesis] Add explicit error message with segfault address (PR #72774)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 18 19:43:25 PST 2023


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

This patch special cases the segfault case for the subprocess executor, giving the exact address of a segfault when one occurs in the subprocess. This makes it a lot easier to debug where things are going wrong in the snippet.

>From 4c98ab8d801a5d8aa25268327bda556c4388d13d Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 18 Nov 2023 19:41:29 -0800
Subject: [PATCH] [llvm-exegesis] Add explicit error message with segfault
 address

This patch special cases the segfault case for the subprocess executor,
giving the exact address of a segfault when one occurs in the
subprocess. This makes it a lot easier to debug where things are going
wrong in the snippet.
---
 .../tools/llvm-exegesis/X86/latency/subprocess-segfault.s   | 4 ++--
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp            | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s b/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s
index bc01c607f0721ca..643d36022893a89 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s
@@ -2,10 +2,10 @@
 
 # RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mode=latency -snippets-file=%s -execution-mode=subprocess | FileCheck %s
 
-# CHECK: error:           'The benchmarking subprocess sent unexpected signal: Segmentation fault'
+# CHECK: error:           A segmentation fault occurred at address 10000
 
 # TODO: Sometimes transiently fails on PTRACE_ATTACH
 # ALLOW_RETRIES: 2
 
-# LLVM-EXEGESIS-DEFREG RBX 0
+# LLVM-EXEGESIS-DEFREG RBX 10000
 movq (%rbx), %rax
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 7ec24eb2f866f86..b735b4d1037c53d 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -343,6 +343,12 @@ class SubProcessFunctionExecutorImpl
                                  Twine(strerror(errno)));
     }
 
+    if (ChildSignalInfo.si_signo == SIGSEGV)
+      return make_error<SnippetCrash>(
+          "A segmentation fault occurred at address " +
+          Twine::utohexstr(
+              reinterpret_cast<intptr_t>(ChildSignalInfo.si_addr)));
+
     return make_error<SnippetCrash>(
         "The benchmarking subprocess sent unexpected signal: " +
         Twine(strsignal(ChildSignalInfo.si_signo)));



More information about the llvm-commits mailing list