Merge pull request #1923 from stweil/errhandling

Don't trigger a deliberate SIGSEGV for fatal errors in release code
This commit is contained in:
zdenop 2018-09-20 21:58:45 +02:00 committed by GitHub
commit 02f9d8d95e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,6 @@ const char *format, ... // special message
// %s is needed here so msg is printed correctly!
fprintf(stderr, "%s", msg);
int* p = nullptr;
switch (action) {
case DBG:
case TESSLOG:
@ -79,8 +78,12 @@ const char *format, ... // special message
case TESSEXIT:
//err_exit();
case ABORT:
#if !defined(NDEBUG)
// Create a deliberate segv as the stack trace is more useful that way.
if (!*p)
// This is done only in debug builds, because the error message
// "segmentation fault" confuses most normal users.
*reinterpret_cast<int*>(0) = 0;
#endif
abort();
default:
BADERRACTION.error ("error", ABORT, nullptr);