-
Notifications
You must be signed in to change notification settings - Fork 10k
ERRCODE::error: throw std::runtime_error instead of abort() #4420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -70,17 +70,11 @@ void ERRCODE::error( // handle error | |||||||||||
return; // report only | ||||||||||||
case TESSEXIT: | ||||||||||||
case ABORT: | ||||||||||||
#if !defined(NDEBUG) | ||||||||||||
// Create a deliberate abnormal exit as the stack trace is more useful | ||||||||||||
// that way. This is done only in debug builds, because the | ||||||||||||
// error message "segmentation fault" confuses most normal users. | ||||||||||||
# if defined(__GNUC__) | ||||||||||||
__builtin_trap(); | ||||||||||||
# else | ||||||||||||
*reinterpret_cast<int *>(0) = 0; | ||||||||||||
# endif | ||||||||||||
#endif | ||||||||||||
abort(); | ||||||||||||
// This used to trigger a segfault or abort(); | ||||||||||||
// However, at least for library use, only exceptions should be acceptable. | ||||||||||||
// Even in the standalone application case, exceptions are better, | ||||||||||||
// because the default handler will print the message along with the stack trace. | ||||||||||||
Comment on lines
+73
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is more precise. But I'd like to also comment what used to be the behaviour. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There used to be comments about the history of some code parts in the past, but most of them are removed in the recent code. I don't think that new comments of this kind are helpful. |
||||||||||||
throw std::runtime_error(msg.str()); | ||||||||||||
default: | ||||||||||||
BADERRACTION.error("error", ABORT); | ||||||||||||
} | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it? It does not print a stack trace in my test on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux, I get:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a stack trace. And please rebase your code with all recent updates from the main branch. Then you will no longer get a core dump.