aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile6
-rw-r--r--src/abort_handler.c21
-rw-r--r--src/benchmark.py8
3 files changed, 33 insertions, 2 deletions
diff --git a/src/Makefile b/src/Makefile
index 2d94a9f..b0584b1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -13,7 +13,7 @@ LDFLAGS ?= -pthread -static-libgcc
MEMSIZE_KB=$(shell free -t | tail -1 | tr -s ' ' | cut -d ' ' -f 2)
MEMSIZE=$(shell echo $(MEMSIZE_KB)"* 1024" | bc)
-TOOLS = print_status_on_exit.so exec
+TOOLS = print_status_on_exit.so exec abort_handler.so
ALLOCS = chattymalloc.so bumpptr_alloc.so speedymalloc.so
TARGETS = $(addprefix $(OBJDIR)/allocators/,$(ALLOCS)) $(addprefix $(OBJDIR)/,$(TOOLS))
@@ -37,6 +37,10 @@ $(OBJDIR)/print_status_on_exit.so: print_status_on_exit.c Makefile
@if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi
$(CC) $(LDFLAGS) -shared $(CFLAGS) -o $@ $<
+$(OBJDIR)/abort_handler.so: abort_handler.c Makefile
+ @if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi
+ $(CC) $(LDFLAGS) -shared $(CFLAGS) -o $@ $<
+
$(OBJDIR)/exec: exec.c Makefile
@if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
diff --git a/src/abort_handler.c b/src/abort_handler.c
new file mode 100644
index 0000000..8347f3a
--- /dev/null
+++ b/src/abort_handler.c
@@ -0,0 +1,21 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void abort_handler(__attribute__((unused)) int signo) {
+ fopen("aborted", "w");
+}
+
+static void __attribute__((constructor)) register_abort_handler(void)
+{
+ struct sigaction sa;
+ sa.sa_handler = abort_handler;
+ sigemptyset(&sa.sa_mask);
+
+ if (sigaction(SIGABRT, &sa, NULL) == -1) {
+ perror("sigaction");
+ exit(1);
+ }
+}
+
diff --git a/src/benchmark.py b/src/benchmark.py
index 798cbd6..f2aa8a3 100644
--- a/src/benchmark.py
+++ b/src/benchmark.py
@@ -345,6 +345,7 @@ class Benchmark:
env = dict(os.environ)
env["LD_PRELOAD"] = env.get("LD_PRELOAD", "")
env["LD_PRELOAD"] += " " + f"{src.globalvars.builddir}/print_status_on_exit.so"
+ env["LD_PRELOAD"] += " " + f"{src.globalvars.builddir}/abort_handler.so"
env["LD_PRELOAD"] += " " + alloc["LD_PRELOAD"]
if "LD_LIBRARY_PATH" in alloc:
@@ -406,7 +407,10 @@ class Benchmark:
result = {}
- if res.returncode != 0 or "ERROR: ld.so" in res.stderr or "Segmentation fault" in res.stderr:
+ if any([res.returncode != 0,
+ "ERROR: ld.so" in res.stderr,
+ "Segmentation fault" in res.stderr,
+ os.path.exists("aborted")]):
print()
print_debug("Stdout:\n" + res.stdout)
print_debug("Stderr:\n" + res.stderr)
@@ -414,6 +418,8 @@ class Benchmark:
print_error("{} failed with exit code {} for {}".format(argv, res.returncode, alloc_name))
elif "ERROR: ld.so" in res.stderr:
print_error("Preloading of {} failed for {}".format(alloc["LD_PRELOAD"], alloc_name))
+ elif os.path.exists("aborted"):
+ os.remove("aborted")
# parse and store results
else: