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() {
generate_trace(1).print( try { // try/catch can never be hit but it's needed to prevent TCO
std::cerr, generate_trace(1).print(
isatty(stderr_fileno), std::cerr,
true, isatty(stderr_fileno),
"Stack trace to reach terminate handler (most recent call first):" true,
); "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() {