[ https://issues.apache.org/jira/browse/LOGCXX-575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17744005#comment-17744005 ]
Robert Middleton commented on LOGCXX-575: ----------------------------------------- It looks like this was recently fixed(https://github.com/apache/logging-log4cxx/commit/1c2ffbfe693d7561b9cf7116568bdc95d95aabd6). Would you be able to test with the current code from master to ensure that it works for you? I was able to confirm that a segfault happens in 1.0.0 and 1.1.0, but it does not happen with the current master. > FileWatchdog runs during log4cxx destructor > ------------------------------------------- > > Key: LOGCXX-575 > URL: https://issues.apache.org/jira/browse/LOGCXX-575 > Project: Log4cxx > Issue Type: Bug > Components: Configurator > Affects Versions: 1.0.0 > Environment: Oracle 8.6 (RHEL 8.6 clone) on WSL2 running in Windows 11 > Reporter: Christopher Meacham > Priority: Major > > The following code results in a segmentation fault in the FileWatchdog::run() > method. > > {code:java} > #include <chrono> > #include <thread> > #include <log4cxx/logger.h> > #include <log4cxx/logmanager.h> > #include <log4cxx/defaultconfigurator.h> > int main() { > using namespace std::chrono_literals; > log4cxx::DefaultConfigurator::setConfigurationWatchSeconds(5); > log4cxx::LoggerPtr log; > log = log4cxx::LogManager::getLogger("main"); > log->info("Test log message", log4cxx::spi::LocationInfo(__FILE__, > /*splitFolder(*/__FILE__/*)*/, __PRETTY_FUNCTION__, __LINE__)); > log4cxx::DefaultConfigurator::setConfigurationWatchSeconds(0); > // std::this_thread::sleep_for(5000ms); > return 0; > } {code} > With the following Environment Variables: > > > {code:java} > LOG4CXX_CONFIGURATION=../testlog4cxx.properties.xml{code} > And the {{testlog4cxx.properties.xml}} contents: > > {code:java} > <?xml version="1.0" encoding="UTF-8" ?> > <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> > <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender"> > <param name="Target" value="System.out"/> > <layout class="org.apache.log4j.PatternLayout"> > <param name="ConversionPattern" value="%d{HH:mm:ss.SSS} [%thread] > %Y%-5p%y %logger{36} (%l:%M()) - %n %Y%m%n%y"/> > </layout> > </appender> > <appender name="FileAppender" class="org.apache.log4j.FileAppender"> > <param name="Append" value="false" /> > <param name="file" value="logging.log" /> > <layout class="org.apache.log4j.PatternLayout"> > <param name="ConversionPattern" value="%d{HH:mm:ss.SSS} [%thread] > %Y%-5p%y %logger{36} (%l:%M()) - %n %Y%m%n%y"/> > </layout> > </appender> > <root> > <priority value="debug" /> > <appender-ref ref="ConsoleAppender"/> > <appender-ref ref="FileAppender"/> > </root> > </log4j:configuration> {code} > The stack trace for the FileWatchdog::run() thread: > {code:java} > #0 0x0000000000433644 in > log4cxx::helpers::LogLog::debug(std::__cxx11::basic_string<char, > std::char_traits<char>, std::allocator<char> > const&) () > #1 0x00000000004212b4 in log4cxx::helpers::FileWatchdog::run() () > #2 0x0000000000422938 in void std::__invoke_impl<void, void > (log4cxx::helpers::FileWatchdog::*)(), > log4cxx::helpers::FileWatchdog*>(std::__invoke_memfun_deref, void > (log4cxx::helpers::FileWatchdog::*&&)(), log4cxx::helpers::FileWatchdog*&&) () > #3 0x00000000004223ec in std::__invoke_result<void > (log4cxx::helpers::FileWatchdog::*)(), log4cxx::helpers::FileWatchdog*>::type > std::__invoke<void (log4cxx::helpers::FileWatchdog::*)(), > log4cxx::helpers::FileWatchdog*>(void > (log4cxx::helpers::FileWatchdog::*&&)(), log4cxx::helpers::FileWatchdog*&&) () > #4 0x0000000000423551 in decltype (__invoke((_S_declval<0ul>)(), > (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void > (log4cxx::helpers::FileWatchdog::*)(), log4cxx::helpers::FileWatchdog*> > >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) () > #5 0x000000000042350c in std::thread::_Invoker<std::tuple<void > (log4cxx::helpers::FileWatchdog::*)(), log4cxx::helpers::FileWatchdog*> > >::operator()() () > #6 0x00000000004234f0 in > std::thread::_State_impl<std::thread::_Invoker<std::tuple<void > (log4cxx::helpers::FileWatchdog::*)(), log4cxx::helpers::FileWatchdog*> > > >::_M_run() () > #7 0x00007ffff321fba3 in execute_native_thread_routine () from > /usr/lib64/libstdc++.so.6 > #8 0x00007ffff393a1df in start_thread () from /usr/lib64/libpthread.so.0 > #9 0x00007ffff2836d83 in clone () from /usr/lib64/libc.so.6 > {code} > The stack trace for the main thread: > {code:java} > #0 0x00007ffff393b6cd in __pthread_timedjoin_ex () from > /usr/lib64/libpthread.so.0 > #1 0x00007ffff321fe27 in std::thread::join() () from > /usr/lib64/libstdc++.so.6 > #2 0x0000000000420d20 in log4cxx::helpers::FileWatchdog::~FileWatchdog() () > #3 0x000000000043c7c2 in > log4cxx::ConfiguratorWatchdog::~ConfiguratorWatchdog() () > #4 0x000000000043c7de in > log4cxx::ConfiguratorWatchdog::~ConfiguratorWatchdog() () > #5 0x0000000000473873 in log4cxx::helpers::APRInitializer::stopWatchDogs() () > #6 0x00000000004737a0 in log4cxx::helpers::APRInitializer::~APRInitializer() > () > #7 0x00007ffff284e1ec in __run_exit_handlers () from /usr/lib64/libc.so.6 > #8 0x00007ffff284e320 in exit () from /usr/lib64/libc.so.6 > #9 0x00007ffff2837caa in __libc_start_main () from /usr/lib64/libc.so.6 > #10 0x000000000040982e in _start () > {code} > > -- This message was sent by Atlassian Jira (v8.20.10#820010)