You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "cmcfarlen (via GitHub)" <gi...@apache.org> on 2026/10/02 19:05:14 UTC

Re: [PR] Report an exception escaping main instead of terminating [trafficserver]

cmcfarlen commented on code in PR #13733:
URL: https://github.com/apache/trafficserver/pull/13733#discussion_r4168917801


##########
src/traffic_server/traffic_server.cc:
##########
@@ -2546,6 +2549,12 @@ main(int /* argc ATS_UNUSED */, const char **argv)
     std::exit(1);
   }
 #endif
+} catch (std::exception const &ex) {

Review Comment:
   Catching here loses the core's most useful part. With no handler anywhere, libstdc++ and libc++ call `std::terminate` from the unwinder's search phase without unwinding, so the core's backtrace ends at the `throw` in the function that failed. Once `main` has a handler, the runtime unwinds every frame back to this catch before `ink_abort()` runs, and the core shows only `main -> ink_abort -> abort` plus `what()`. The throw site is the evidence the description says this keeps.
   
   It also only covers the main thread; exceptions on EThreads never pass through here.
   
   I'd leave `traffic_server.cc` out of this PR and dismiss the Coverity report for it. If the message is wanted, a `std::set_terminate` handler that logs `std::current_exception()` and then aborts runs before any unwinding, so the stack is still intact.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org