From 62d4cb138b678c77f620e5bf7ff6a8a5cc0ed9a7 Mon Sep 17 00:00:00 2001 From: Stephen Webb Date: Fri, 19 Jul 2024 17:41:48 +1000 Subject: [PATCH] Reduce the frequency of unit test failures --- src/main/cpp/loggingevent.cpp | 2 +- src/test/cpp/asyncappendertestcase.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp index 690102025..a0f25c5e6 100644 --- a/src/main/cpp/loggingevent.cpp +++ b/src/main/cpp/loggingevent.cpp @@ -383,7 +383,7 @@ const LogString& LoggingEvent::getCurrentThreadUserName() #if LOG4CXX_HAS_THREAD_LOCAL thread_local LogString thread_name; #else - static WideLife thread_name = LOG4CXX_STR("(noname)"); + static LogString thread_name = LOG4CXX_STR("(noname)"); #endif if( !thread_name.empty() ){ return thread_name; diff --git a/src/test/cpp/asyncappendertestcase.cpp b/src/test/cpp/asyncappendertestcase.cpp index 33b2f3717..6a960c57f 100644 --- a/src/test/cpp/asyncappendertestcase.cpp +++ b/src/test/cpp/asyncappendertestcase.cpp @@ -17,6 +17,9 @@ #include "logunit.h" +#define LOG4CXX_TEST 1 +#include + #include #include #include @@ -250,7 +253,13 @@ class AsyncAppenderTestCase : public AppenderSkeletonTestCase { for (size_t i = 0; i < LEN; i++) { +// As at 2024-7-19 the msys2 ucrt-x86_64 runtime terminates with error c0000374 during thread local data cleanup +// The call to debug() avoids the use of the thread_local data in MessageBuffer +#if LOG4CXX_HAS_THREAD_LOCAL && LOG4CXX_HAS_PTHREAD_SELF && !(defined(_WIN32) && defined(_LIBCPP_VERSION)) + root->debug("message" + std::to_string(i)); +#else LOG4CXX_DEBUG(root, "message" << i); +#endif } }); }