Add another try/catch to prevent any potential TCO

This commit is contained in:
Jeremy 2024-07-13 19:07:58 -05:00
parent dcf89743f6
commit cc2b3fce40
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4

View File

@ -441,12 +441,18 @@ namespace cpptrace {
extern const int stderr_fileno = detail::fileno(stderr); extern const int stderr_fileno = detail::fileno(stderr);
CPPTRACE_FORCE_NO_INLINE void print_terminate_trace() { CPPTRACE_FORCE_NO_INLINE void print_terminate_trace() {
try { // try/catch can never be hit but it's needed to prevent TCO
generate_trace(1).print( generate_trace(1).print(
std::cerr, std::cerr,
isatty(stderr_fileno), isatty(stderr_fileno),
true, true,
"Stack trace to reach terminate handler (most recent call first):" "Stack trace to reach terminate handler (most recent call first):"
); );
} catch(...) {
if(!detail::should_absorb_trace_exceptions()) {
throw;
}
}
} }
[[noreturn]] void terminate_handler() { [[noreturn]] void terminate_handler() {