Skip to content

Commit

Permalink
Abort at uncatched exceptions
Browse files Browse the repository at this point in the history
Change a remaining assert(0) call to FATAL_ERROR(msg).
There was a regression since commit

ced6d20 "For usages of assert() that are meant to persist in Release builds (when NDEBUG is defined), replace those usages with persistent alternatives"

where when an "uncatched" exception is thrown inside a "side thread",
the program doesn't abort anymore.

This led to the problem @netinetwalker experienced where the emergethread
got an unhandled exception for loading a mapblock while redis was loading,
(see #3196) and then jmped outside its loop to work down its queue.
This resulted in the server not doing any emerges anymore.
  • Loading branch information
est31 committed Sep 26, 2015
1 parent 4338f10 commit e728281
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/debug.h
Expand Up @@ -42,7 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif

// Whether to catch all std::exceptions.
// Assert will be called on such an event.
// When "catching", the program will abort with an error message.
// In debug mode, leave these for the debugger and don't catch them.
#ifdef NDEBUG
#define CATCH_UNHANDLED_EXCEPTIONS 1
Expand Down Expand Up @@ -145,11 +145,11 @@ class DebugStacker

#if CATCH_UNHANDLED_EXCEPTIONS == 1
#define BEGIN_DEBUG_EXCEPTION_HANDLER try {
#define END_DEBUG_EXCEPTION_HANDLER(logstream) \
} catch (std::exception &e) { \
logstream << "ERROR: An unhandled exception occurred: " \
<< e.what() << std::endl; \
assert(0); \
#define END_DEBUG_EXCEPTION_HANDLER(logstream) \
} catch (std::exception &e) { \
logstream << "An unhandled exception occurred: " \
<< e.what() << std::endl; \
FATAL_ERROR(e.what()); \
}
#else
// Dummy ones
Expand Down

0 comments on commit e728281

Please sign in to comment.