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


##########
tests/uranium_tests/pluginTest/crash_test/crash_test.cc:
##########
@@ -24,19 +24,30 @@
  * This plugin is for TESTING ONLY - do not use in production!
  *
  * When a request contains the header "X-Crash-Test: now", this plugin
- * will dereference a null pointer, causing a SIGSEGV.
+ * will dereference a null pointer, causing a SIGSEGV. When the header value
+ * is "throw", it throws a std::runtime_error out of the hook instead, which
+ * nothing catches.
  */
 
 #include <ts/ts.h>
 #include <cstring>
 #include <cstdlib>
+#include <stdexcept>
 
 #define PLUGIN_NAME "crash_test"
 
 namespace
 {
 DbgCtl dbg_ctl{PLUGIN_NAME};
 
+// Kept out of line so this frame, and its name, shows up in the crash log
+// backtrace of the thread that threw.
+[[gnu::noinline]] void
+crash_test_throw()
+{
+  throw std::runtime_error("crash_test throw");
+}

Review Comment:
   ATS builds with GCC and Clang, and both support `[[gnu::noinline]]`. It only 
matters on those compilers anyway: it keeps the throwing function as its own 
frame so the test can find it in the backtrace.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to