ywkaras commented on code in PR #11634:
URL: https://github.com/apache/trafficserver/pull/11634#discussion_r1700916506
##########
src/iocore/cache/unit_tests/stub.cc:
##########
@@ -27,6 +27,29 @@
#include "proxy/HttpAPIHooks.h"
+#include "tscore/BaseLogFile.h"
+#include "tscore/Diags.h"
+
+class InitDiags
+{
+public:
+ InitDiags() : base_log_file{new BaseLogFile("stderr")}
+ {
+ DiagsPtr::set(new Diags("cache unit test", "*" /* tags */, "" /* actions
*/, this->base_log_file));
+ }
+
+ ~InitDiags() { delete this->base_log_file; }
+
+private:
+ BaseLogFile *base_log_file;
+};
+
+// The FetchSM class allocator below uses the diags in its constructor, so we
+// force them to be initialized prior to that. This gets "leaked" at shutdown
+// to ensure that the log file remains valid if accessed by other threads
+// during static object destruction.
+InitDiags const *g_init_diags_dummy = new InitDiags{};
Review Comment:
The crash this PR solves would not happen if
https://github.com/apache/trafficserver/pull/11464 got merged. (Maybe someday
@zwoop will come out of his review coma.) The only remaining issue will be
that there will be no way to enable debug trace output during static
initialization.
--
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]