Closed wrohv closed 3 weeks ago
This wasn't the case in prior versions.
In release 1.3 ThreadSpecificData switched from using APR apr_threadkey_private_get
to using C++ thread_local
where the compiler supports thread_local
.
Could you advise us which compiler version you are using?
Are you exiting gracefully(e.g. stopping all threads) when you exit? There are some issues with exiting uncleanly(e.g. by calling exit()
) due to static objects being destroyed while threads may still be running.
I am on MacOS 15.1.
> clang --version
Apple clang version 16.0.0 (clang-1600.0.26.4)
Here's a full reproducing example, where I started from "A Simple Example" at https://logging.apache.org/log4cxx/1.3.0/quick-start.html
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/ndc.h>
static log4cxx::NDC ndc("MyNDC");
static auto logger = log4cxx::Logger::getLogger("MyApp");
int main(int argc, char **argv) {
// Log to standard output.
log4cxx::BasicConfigurator::configure();
LOG4CXX_INFO(logger, "Exiting application.");
return EXIT_SUCCESS;
}
I tried the linked pull request branch and it appears to solve the problem for me. Thanks!
After updating to log4cxx 1.3.0, I find that statically allocated NDC objects cause a segmentation fault at application exit. This wasn't the case in prior versions. I'm on MacOS on arm.
Just adding these lines to any code can cause the issue for me:
The lldb stack trace shows the issue arising from the destructor of the static object: