Skip to content

Commit

Permalink
Print nicer error messages for uncaught exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSully committed May 19, 2019
1 parent e0abbb2 commit af8c82b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NODEPS:=clean distclean

# Default settings
STD=-std=c99 -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
Expand Down
12 changes: 12 additions & 0 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4917,6 +4917,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);
Expand All @@ -4937,6 +4947,8 @@ int main(int argc, char **argv) {
struct timeval tv;
int j;

std::set_terminate(OnTerminate);

#ifdef USE_MEMKIND
storage_init(NULL, 0);
#endif
Expand Down

0 comments on commit af8c82b

Please sign in to comment.