log4cxx is throwing exception on ~Logger -
log4cxx is throwing exception on ~Logger -
i started log4cxx doing little app familiar it. compiled visual studio 2005, no warnings or errors. looks :
#includes<...> ... ... loggerptr logger(logger::getlogger("myapp")); void main(...) { //some logs here }
it works expected until close app when exception while trying destroy global logger object. here trace:
log4cxx.dll!apr_pool_cleanup_kill(apr_pool_t * p=0xdddddddd, const void * data=0x01cf6158, int (void *)* cleanup_fn=0x10174250) line 1981 + 0x3 bytes log4cxx.dll!apr_pool_cleanup_run(apr_pool_t * p=0xdddddddd, void * data=0x01cf6158, int (void *)* cleanup_fn=0x10174250) line 2025 log4cxx.dll!apr_thread_mutex_destroy(apr_thread_mutex_t * mutex=0x01cf6158) line 133 log4cxx.dll!log4cxx::helpers::mutex::~mutex() line 57 log4cxx.dll!log4cxx::logger::~logger() line 55 + 0xb bytes log4cxx.dll!log4cxx::logger::`vbase destructor'() + 0x19 bytes log4cxx.dll!log4cxx::logger::`vector deleting destructor'() + 0x5a bytes log4cxx.dll!log4cxx::helpers::objectimpl::releaseref() line 46 + 0x39 bytes log4cxx.dll!log4cxx::logger::releaseref() line 63 log4cxx.dll!log4cxx::helpers::objectptrt<log4cxx::logger>::~objectptrt<log4cxx::logger>() line 100 + 0x33 bytes nodebheartbeat.exe!`dynamic atexit destructor 'logger''() + 0x2b bytes msvcr80d.dll!doexit(int code=0x00000000, int quick=0x00000000, int retcaller=0x00000001) line 553 msvcr80d.dll!_cexit() line 413 + 0xb bytes msvcr80d.dll!__crtdll_init(void * hdllhandle=0x6c710000, unsigned long dwreason=0x00000000, void * lpreserved=0x00000001) line 389 msvcr80d.dll!_crtdll_init(void * hdllhandle=0x6c710000, unsigned long dwreason=0x00000000, void * lpreserved=0x00000001) line 214 + 0x11 bytes ntdll.dll!774b9960()
anybody has thought why happening ? thanks
i managed around problem assigning "0" logger pointer.
the magic trick located within log4cxx source code in file src/main/include/log4cxx/helpers/objectptr.h
that is, releaseref() giving indirect command on object destruction order.
... ... objectptrt& operator=(const int& null) //throw(illegalargumentexception) { // // throws illegalargumentexception if null != 0 // objectptrbase::checknull(null); t* oldptr = exchange(0); if (oldptr != 0) { oldptr->releaseref(); } homecoming *this; } ... ...
so, code, add together line @ end :
#includes<...> ... ... loggerptr logger(logger::getlogger("myapp")); void main(...) { //some logs here logger = 0; // release reference pointer // create sure no other reference logger exist // ie: thread used re-create constructor on logger object. }
log4cxx
Comments
Post a Comment