Hi,
We are using log4cpp in our logger(ys_logger) and when an Apache process
exits,
we see that log4cpp destructor(~Category) is being invoked before our
logger's destructor.
Since in our logger destructor, we are trying to do a final flushing of logs
to the files, we are seg faulting on accessing the log4cpp instance.
valgrind:
Invalid read of size 4
at 0x2D31E04E: log4cpp::Category::getAllAppenders(void) const
(/home/y/include/g++/stl_tree.h:668)
by 0x2D25602C: ys::logger::LoggerImpl::~LoggerImpl(void)
by 0x2D24B7FF: ys::logger::Logger::~Logger(void)
(/home/y/include/ys/core/Refcounted.hh:37)
Address 0x2EE0D7E8 is 16 bytes inside a block of size 48 free'd
at 0x2D0276DB: __builtin_delete (in
/usr/local/lib/valgrind/vgpreload_memcheck.so)
by 0x2D31D712: log4cpp::Category::~Category(void) (Category.cpp:61)
by 0x2D323663: log4cpp::HierarchyMaintainer::deleteAllCategories(void)
(HierarchyMaintainer.cpp:110)
by 0x2D322EA8: log4cpp::HierarchyMaintainer::~HierarchyMaintainer(void)
(HierarchyMaintainer.cpp:36)
Isn't log4cpp a refcounted class? why is this happening?
We do this for log4cpp instantiation:
log4cpp::Category& logger =
log4cpp::Category::getInstance(l_logger->m_name);
l_logger->m_logger = &logger;
and the segfaulting happens in
AppenderSet appenders = m_logger->getAllAppenders();
Not sure of
1. how to ensure the order of destructors are correct on loading?
2. if there is any hook in apache, which can be used to do a final flush (of
logs to a file) before any of the destructors are getting called, so that I
can go ahead and remove any sore of log4cpp accesses from ystore_logger's
destructors?
Attempted patch-sys-rtld- it did not help.
Thanks,
priya