From: waffel <wa...@us...> - 2010-01-26 07:44:47
|
Hi, ok ... I do not have anymore enough time to maintain log4cpp on a regular base .. but I can push out a security fix release the next days with your fix. Can you please send me the patch as attachement or better would be to add an bug entry on our sourceforge page with your patch? I will also send your mail to our maillinglist so anybody covers the memory leak too. Kind regards, - waffel Am 24.01.2010 22:54, schrieb cquike: > > Message body follows: > > Dear Thomas, > first of all sorry for not addressing this email to the > right person. I just > saw it as the maintainer of the log4cpp library. > I have been using the library and have found a memory leak. > Using the code snippet from > http://developers.sun.com/solaris/articles/logging.html and > running valgrind I get a memory leak report : > ==31205== 24 bytes in 1 blocks are still reachable in loss > record 1 of 1 > ==31205== at 0x4025390: operator new(unsigned int) > (vg_replace_malloc.c:214) > ==31205== by 0x4054E8B: > log4cpp::Appender::_getAllAppenders() (in > /usr/lib/liblog4cpp.so.5.0.5) > ==31205== by 0x405542F: > log4cpp::Appender::_addAppender(log4cpp::Appender*) (in > /usr/lib/liblog4cpp.so.5.0.5) > ==31205== by 0x40556B1: > log4cpp::Appender::Appender(std::string const&) (in > /usr/lib/liblog4cpp.so.5.0.5) > ==31205== by 0x40562C8: > log4cpp::AppenderSkeleton::AppenderSkeleton(std::string > const&) (in /usr/lib/liblog4cpp.so.5.0.5) > ==31205== by 0x405B4CB: > log4cpp::LayoutAppender::LayoutAppender(std::string const&) > (in /usr/lib/liblog4cpp.so.5.0.5) > ==31205== by 0x405B7FF: > log4cpp::FileAppender::FileAppender(std::string const&, > std::string const&, bool, unsigned int) (in > /usr/lib/liblog4cpp.so.5.0.5) > ==31205== by 0x8048F6A: main (testlog.cpp:13) > The memory leak is related to the Appender class, namely > the _allAppenders variable. I solved the problem using a > std::auto_ptr. > The patch is simple: > --- log4cpp-1.0/src/Appender.cpp 2007-08-02 > 15:20:26.000000000 +0200 > +++ log4cpp-1.0.modified/src/Appender.cpp 2010-01-23 > 23:44:41.000000000 +0100 > @@ -11,13 +11,13 @@ > #include<log4cpp/Appender.hh> > > namespace log4cpp { > - Appender::AppenderMap* Appender::_allAppenders = 0; > + std::auto_ptr<Appender::AppenderMap> > Appender::_allAppenders(0); > threading::Mutex Appender::_appenderMapMutex; > > /* assume _appenderMapMutex locked */ > Appender::AppenderMap& Appender::_getAllAppenders() { > - if (!_allAppenders) > - _allAppenders = new Appender::AppenderMap(); > + if (_allAppenders.get() == 0) > + _allAppenders.reset( new Appender::AppenderMap()); > > return *_allAppenders; > } > > You may find the patch in attachment memory_leak_fixed.patch. > I would like to know if there are plans to have a new > release of the library (hopefully with this problem fixed). > If you are not longer the maintainer I would appreciate if > you point me who should I address to. > > Thank you very much in advance, > Enrique > > -- > This message has been sent to you, a registered SourceForge.net user, > by another site user, through the SourceForge.net site. This message > has been delivered to your SourceForge.net mail alias. You may reply > to this message using the "Reply" feature of your email client, or > using the messaging facility of SourceForge.net at: > https://sourceforge.net/sendmessage.php?touser=1178969 > |