From 7adf80fccdb4312e17ed350bd532195a0cd7977d Mon Sep 17 00:00:00 2001 From: iko1 Date: Sat, 9 Jul 2022 22:36:05 +0300 Subject: [PATCH] fix(server): setup sigill handler (#183) (#198) Signed-off-by: iko1 --- src/server/dfly_main.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/server/dfly_main.cc b/src/server/dfly_main.cc index bc229ee29..53c46b67a 100644 --- a/src/server/dfly_main.cc +++ b/src/server/dfly_main.cc @@ -1,3 +1,4 @@ + // Copyright 2022, Roman Gershman. All rights reserved. // See LICENSE for licensing terms. // @@ -6,6 +7,7 @@ #include #endif +#include #include #include #include @@ -137,6 +139,13 @@ extern "C" void _mi_options_init(); using namespace dfly; +void sigill_hdlr(int signo) { + LOG(ERROR) + << "An attempt to execute an instruction failed." + << "The root cause might be an old hardware. Exiting..."; + exit(1); +} + int main(int argc, char* argv[]) { absl::SetProgramUsageMessage( R"(a modern in-memory store. @@ -157,6 +166,11 @@ Usage: dragonfly [FLAGS] MainInitGuard guard(&argc, &argv); + struct sigaction act; + act.sa_handler = sigill_hdlr; + sigemptyset(&act.sa_mask); + sigaction(SIGILL, &act, nullptr); + CHECK_GT(GetFlag(FLAGS_port), 0u); mi_stats_reset();