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