Hello,
I just started with using log4cxx. It's a nice logging library and I
like using it. But for some reason I get a crash at exiting my program.
I run it in the debugger and here is the result:
Program received signal SIGSEGV, Segmentation fault.
0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized out>)
at /usr/include/log4cxx/helpers/objectptr.h:100
100 p->releaseRef();
(gdb) bt
#0 0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized out>)
at /usr/include/log4cxx/helpers/objectptr.h:100
#1 0x0093d2cf in std::_Rb_tree<std::string, std::pair<std::string const,
std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>,
std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > >,
std::_Select1st<std::pair<std::string const,
std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>,
std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > > >,
std::less<std::string>, std::allocator<std::pair<std::string const,
std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>,
std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > > >
>::_M_erase(std::_Rb_tree_node<std::pair<std::string const,
std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>,
std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > > >*) () from
/usr/lib/liblog4cxx.so.10
#2 0x0093b4a4 in log4cxx::Hierarchy::~Hierarchy() () from
/usr/lib/liblog4cxx.so.10
#3 0x00961b75 in log4cxx::helpers::ObjectImpl::releaseRef() const () from
/usr/lib/liblog4cxx.so.10
#4 0x00939972 in log4cxx::Hierarchy::releaseRef() const () from
/usr/lib/liblog4cxx.so.10
#5 0x009561f7 in
log4cxx::spi::DefaultRepositorySelector::~DefaultRepositorySelector() ()
from /usr/lib/liblog4cxx.so.10
#6 0x00961b75 in log4cxx::helpers::ObjectImpl::releaseRef() const () from
/usr/lib/liblog4cxx.so.10
#7 0x0091d832 in log4cxx::spi::DefaultRepositorySelector::releaseRef() const
() from /usr/lib/liblog4cxx.so.10
#8 0x00956099 in
log4cxx::helpers::ObjectPtrT<log4cxx::spi::RepositorySelector>::~ObjectPtrT() ()
from /usr/lib/liblog4cxx.so.10
#9 0x00702588 in __cxa_finalize (d=0xa0338c) at cxa_finalize.c:56
#10 0x009001e4 in ?? () from /usr/lib/liblog4cxx.so.10
#11 0x009adcd0 in _fini () from /usr/lib/liblog4cxx.so.10
#12 0x0011e216 in _dl_fini () at dl-fini.c:248
#13 0x007021bf in __run_exit_handlers (status=0, listp=0x829324,
run_list_atexit=true) at exit.c:78
#14 0x0070222f in *__GI_exit (status=0) at exit.c:100
#15 0x006e9bde in __libc_start_main (main=0x806124d <main>, argc=1,
ubp_av=0xbfffee54,
init=0x80636a0 <__libc_csu_init>, fini=0x8063690 <__libc_csu_fini>,
rtld_fini=0x11e030 <_dl_fini>,
---Type <return> to continue, or q <return> to quit---
stack_end=0xbfffee4c) at libc-start.c:258
#16 0x080534f1 in _start ()
Maybe it's a problem how I use log4cxx. I defined a stupid wrapper class for my
project:
http://codepad.org/EWDVx8mE
This helps me to cut down dependencies (e.g. for a win32 build where no
development happens).
Then I use the Logger object like this:
in the application:
// all needed includes and namespaces direct
...
PropertyConfigurator::configure (searchDataDir () + "/logging.prop");
and then the wrapper in the library (only cpp files!)
static Logger logger ("stateval.StateMachineThread");
void MyClass::myFucntion ()
{
LOG4CXX_TRACE (logger, "a trace");
}
The logging works, but it crashes at exit...
I won't like to put Logger as member in the Header files to cut down
dependencies. And it needs to be static for sure...
So have you any ideas what I made wrong here?
Have you any experiences how you organise your logger variables
in your source code?
regards
Andreas