From 67d94eee12c4405cec2cbd84d8f9d99dcced1ec1 Mon Sep 17 00:00:00 2001 From: John Sully Date: Sat, 18 May 2019 20:22:16 -0400 Subject: [PATCH] Print nicer error messages for uncaught exceptions Former-commit-id: 23b0268a7fc1f7116e96905502895a445d2caf76 --- src/Makefile | 2 +- src/server.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index aa7b204ff..c197d0927 100644 --- a/src/Makefile +++ b/src/Makefile @@ -21,7 +21,7 @@ NODEPS:=clean distclean # Default settings STD=-std=c11 -pedantic -DREDIS_STATIC='' -CXX_STD=-std=c++14 -pedantic -fno-rtti -fno-exceptions -D__STDC_FORMAT_MACROS +CXX_STD=-std=c++14 -pedantic -fno-rtti -D__STDC_FORMAT_MACROS ifneq (,$(findstring clang,$(CC))) ifneq (,$(findstring FreeBSD,$(uname_S))) STD+=-Wno-c11-extensions diff --git a/src/server.cpp b/src/server.cpp index f7b7dba3f..af62c78c3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4919,6 +4919,16 @@ void incrementMvccTstamp() } } +void OnTerminate() +{ + /* Any uncaught exception will call std::terminate(). + We want this handled like a segfault (printing the stack trace etc). + The easiest way to achieve that is to acutally segfault, so we assert + here. + */ + serverAssert(false); +} + void *workerThreadMain(void *parg) { int iel = (int)((int64_t)parg); @@ -4939,6 +4949,8 @@ int main(int argc, char **argv) { struct timeval tv; int j; + std::set_terminate(OnTerminate); + #ifdef USE_MEMKIND storage_init(NULL, 0); #endif