Hi there

I have a program that defines some static objects which are derived from 
a class that contains a log4cxx::LogPtr member (as I noticed this 
somehow emulates Java's referenced counting for object references). When 
the program exits (when the exit codes call the object destructors for 
the "static/global" objects) I get a crash and valgrind clearly points 
out that one of my destructors is trying to use log4cxx on an object 
that somehow has been cleaned up already from 
~DefaultRepositorySelector, with this message:
==17520==    at 0x12085D8F: log4cxx::Logger::isDebugEnabled() const 
(logger.cpp:263)
==17520==    by 0x47C01E: ~myClass() (objectptr.h:159)
==17520==    by 0x133D5F04: exit (in /lib64/tls/libc-2.3.5.so)
==17520==    by 0x133C167A: __libc_start_main (in /lib64/tls/libc-2.3.5.so)
==17520==    by 0x40C989: (within servd)
==17520==  Address 0x1384F7F8 is 0 bytes inside a block of size 208 free'd
==17520==    at 0x11B1AFE3: operator delete(void*) (vg_replace_malloc.c:246)
==17520==    by 0x1208E58B: 
log4cxx::spi::DefaultRepositorySelector::~DefaultRepositorySelector() 
(objectptr.h:88)
==17520==    by 0x133D5F04: exit (in /lib64/tls/libc-2.3.5.so)

Now, I have tried to somehow reproduce this with a testcase but I am 
unable to. AFAIK ISO C++ says that there is no guaranteed order of 
calling the destructors of global/static objects across different 
translation units as such it is possible to have the static/global objects 
destructors of log4cxx library called BEFORE any other user of it's objects 
finishes. But I thought this is what LogPtr reference counted is used for, 
to make sure no such object is destroyed before every user releases it's 
reference to it. It is possible that ~DefaultRepositorySelector() 
destroys "loggers" even that there are LogPtr objects referencing them ? 
:(

Do I miss something ? Please help!

Thanks!

-- 
Mihai RUSU                                    Email: [EMAIL PROTECTED]
GPG : http://dizzy.roedu.net/dizzy-gpg.txt    WWW: http://dizzy.roedu.net
                       "Linux is obsolete" -- AST

Reply via email to