logo       

Re: apps throwing MutexException at termination: msg#00011

Subject: Re: apps throwing MutexException at termination
Thanks Curt.  I'll give it a try.



Curt Arnold-3 wrote:
> 
> Please try the following patch and see if it resolves your problem.   
> Reworking ObjectPtrBase::exchange for 64-bit builds was on my TO-DO  
> list, but I wanted to work through the rest of the backlog before  
> going to platform specific builds.  On 32-bit builds,  
> ObjectPtrBase::exchange calls apr_atomic_xchg32 which on most  
> processors will end up being a single machine instruction.  Until  
> recently APR did not have an equivalent call to exchange pointers (it  
> does now in the SVN, but hasn't appeared in a release yet), so there  
> were calls that used the Mutex abstraction from log4cxx.  What I  
> believe that you are running into is exchange() was first called in  
> the object destructor which means that it could occur after APR has  
> been terminated.  I've modified ObjectPtrBase so that the mutex is  
> accessed in the constructor which should guarantee that it is still  
> available in the matching destructor.   I have not tested the code  
> and it is not what I expect the final fix will be, but it may be  
> enough to get you going.
> 
> Ultimately, I'd expect to use apr_atomic_xchg32 on 32-bit builds,  
> InterlockedExchangePtr on Win64-builds, update configure to test for  
> the presence of apr_atomic_xchgptr and use that if available and only  
> then attempt to use the log4cxx Mutex abstraction.  log4cxx-0.9.7 did  
> not attempt to do any synchronization on object pointers.  If the fix  
> doesn't work for you, let the list know but you should be able to get  
> away with just commenting out the synchronization constructor.
> 
> 
> Index: src/main/cpp/objectptr.cpp
> ===================================================================
> --- src/main/cpp/objectptr.cpp        (revision 582963)
> +++ src/main/cpp/objectptr.cpp        (working copy)
> @@ -26,6 +26,17 @@
> 
>   using namespace log4cxx::helpers;
> 
> +ObjectPtrBase::ObjectPtrBase() {
> +#if APR_SIZEOF_VOIDP != 4
> +    getMutex();
> +#endif
> +}
> +
> +Mutex& ObjectPtrBase::getMutex() {
> +   static Mutex mutex(APRInitializer::getRootPool());
> +   return mutex;
> +}
> +
>   void ObjectPtrBase::checkNull(const int& null) {
>       if (null != 0) {
>          throw IllegalArgumentException("Attempt to set pointer to a  
> non-zero numeric value.");
> @@ -37,8 +48,7 @@
>      return (void*) apr_atomic_xchg32((volatile apr_uint32_t*)  
> destination,
>                             (apr_uint32_t) newValue);
>   #else
> -   static Mutex mutex(APRInitializer::getRootPool());
> -   synchronized sync(mutex);
> +   synchronized sync(getMutex());
>      void* oldValue = *destination;
>      *destination = newValue;
>      return oldValue;
> Index: src/main/include/log4cxx/helpers/objectptr.h
> ===================================================================
> --- src/main/include/log4cxx/helpers/objectptr.h      (revision 582963)
> +++ src/main/include/log4cxx/helpers/objectptr.h      (working copy)
> @@ -37,11 +37,16 @@
>   {
>       namespace helpers
>       {
> +        class Mutex;
> 
>           class LOG4CXX_EXPORT ObjectPtrBase {
>           public:
> +            ObjectPtrBase();
>               static void checkNull(const int& null);
>               static void* exchange(void** destination, void* newValue);
> +
> +        private:
> +            static Mutex& getMutex();
>           };
> 
> 
> 
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/apps-throwing-MutexException-at-termination-tf4590301.html#a13115535
Sent from the Log4cxx - Users mailing list archive at Nabble.com.




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe