-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
Log4cxx 0.13.0 introduced a critical thread safety change that causes applications to crash with SIGSEGV during startup when multiple threads concurrently access Logger::getLogger()
. The issue is caused by commit 6505a08671b4c564f9fb5b237c856c52c126307d
which replaced thread-safe LoggerRepositoryWeakPtr
with unsafe raw LoggerRepository*
pointers.
Environment Details:
- Log4cxx Version: 0.13.0
- Platform: Linux x86_64
- Compiler: GCC 7.5.0, C++14
- Threading: Multi-threaded application with concurrent logger access
- APR Version: 1.7.4
- APR-Util Version: 1.6.3
Problematic Commit:
- Commit Hash:
6505a08671b4c564f9fb5b237c856c52c126307d
- Title: "[LOGCXX-546] Prevent serialization of a multi-threaded application when using disabled logging statements"
- Author: Stephen Webb
- Date: January 1, 2022
Sample Code:
log4cxx::LoggerPtr testlog_control::getTestLoggerFromModuleName( const std::string &module ) const
{
log4cxx::LoggerPtr logger = ( module==rootModuleName ? _rootLogger : log4cxx::Logger::getLogger( module ) );
assert(logger);
return logger;
}
Observed Crash:
#0 read () from /lib64/libc.so.6
#1 sig_handler_bt_exit at /include/bits/unistd.h:38
#2 <signal handler called>
#3 log4cxx::LogManager::getLoggerLS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib64/liblog4cxx.so.13
#4 log4cxx::LogManager::getLogger(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib64/liblog4cxx.so.13
#5 log4cxx::Logger::getLogger(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib64/liblog4cxx.so.13
#6 testlog::testlog_control::getTestLoggerFromModuleName (this=<optimized out>, module=...) at testlog_control.cpp:268
#7 testlog::testlog_control::getTestLogLevel (this=<optimized out>, module=...) at testlog_control.cpp:299
#8 testlog::testlog_control::testlog_control (this=<optimized out>, ident=<optimized out>, logfilename=<optimized out>) at testlog_control.cpp:88
#9 initTestLog (ident=<optimized out>, logfilename=<optimized out>) at testlog_control.cpp:746
#10 applstrtTaskEntry (argv=<optimized out>) at applstrt.cpp:419
#11 main (argc=<optimized out>, argv=<optimized out>) at applstrt.cpp:848
Metadata
Metadata
Assignees
Labels
No labels