logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rhosyn@purplescarab.com" <rho...@purplescarab.com>
Subject apr_terminate called too early...
Date Fri, 15 Oct 2010 20:48:06 GMT
 >From    Thorsten Schöning <tschoening@am-soft.de>
 >reply-to    Log4CXX User <log4cxx-user@logging.apache.org>
 >to    Log4CXX User <log4cxx-user@logging.apache.org>
 >date    15 October 2010 11:14
 >subject    apr_terminate called too early...
 >mailing list <log4cxx-user.logging.apache.org> Filter messages from 
this mailing list
 >I have a GUI-application in Borland C++-Builder 5 which I needed to
 >add logging support using log4cxx. It started fine but I noticed
 >problems after closing the application. Like others on the net I have
 >the problem that the application crashes during accessing or deleting
 >some mutexes during destruction of different objects. Because I didn't
 >find a real solution or advice what might be the problem, just some
 >infos on locking problems or stuff like that, I tried to look into
 >this myself.
 >What I have found is that apr_terminate is called during
 >deconstruction of APRInitializer before the access problems or
 >exceptions occur. This makes sense, because the problem was that some
 >apr-mutexes where inaccessible in some point during application
 >shutdown and all those mutexes are owned by apr, if I understood
 >From my point of view I would have expected that apr_terminate is the
 >last thing called in Log4cxx but it seems that after deconstruction of
 >APRInitializer and apr_terminate deconstructing objects just continues
 >with some Loggers, Appenders etc. All of them use mutexes which aren't
 >available anymore if apr_terminate was called before.
 >It does seem that theres only one instance of APRInitializer available
 >during runtime and that apr_initiliaze is called only once, therefore
 >the one call of apr_terminate I noticed really kills all objects and
 >memory. I didn't understand how and when APRInitializer is
 >deconstructed, though.
 >So, can it be correct that apr_terminate is called before everything
 >else has finished and all Objects using apr-mutexes released them
 >properly? If I uncomment apr_terminate, the application seems to
 >finish properly.
 >Mit freundlichen Grüßen,
 >Thorsten Schöning
 >Thorsten Schöning
 >AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
 >Telefon: Potsdam: 0331-743881-0
 >E-Mail:  tschoening@am-soft.de
 >Web:     http://www.am-soft.de
 >AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
 >Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow

We ran into the same issue viz-a-vis APRInitializer in the product we 
were building - see 

for a discussion.

Ensuring safe order of destruction of objects in C++ (especially if 
there are statics, & also especially so if there are multiple threads) 
is fraught with difficulty.

The ideal solution (imho) would be to implement a "Singleton holder" as 
discussed in the above link to guarantee a correct/safe order of 

However, in the absence of sufficient  time/resources to remodel log4cxx 
along these lines we ended up (as a "dirty" but pragmatic measure) 
patching our log4cxx by commenting out apr_terminate (just as you suggest).



View raw message