log4cxx-0.10.0: Fix for 64 bit-only thread safety bug in ObjectPtrBase

View: New views
6 Messages — Rating Filter:   Alert me  

log4cxx-0.10.0: Fix for 64 bit-only thread safety bug in ObjectPtrBase

by Rhosyn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The attach patch fixes a thread safety issue we found with ObjectPtrBase
when we ported our application to a 64 bit platform.

It will only work if you are using a version of apr with
apr_atomic_xchgptr()


Cheers



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
[objectptr.cpp.threadsafety.patch]

--- /home/rhosyn/SVN/oakx41/main/thirdparty/log4cxx/_build/app.host/app/apache-log4cxx-0.10.0/src/main/cpp/objectptr.cpp 2008-03-31 23:34:09.000000000 +0100
+++ /home/rhosyn/SVN/oakx41/main/thirdparty/log4cxx/_build/app.app/app/apache-log4cxx-0.10.0/src/main/cpp/objectptr.cpp 2009-01-07 15:39:03.000000000 +0000
@@ -36,12 +36,7 @@
 void* ObjectPtrBase::exchange(void** destination, void* newValue) {
 #if _WIN32 && (!defined(_MSC_VER) || _MSC_VER >= 1300)
     return InterlockedExchangePointer(destination, newValue);
-#elif APR_SIZEOF_VOIDP == 4
-   return (void*) apr_atomic_xchg32((volatile apr_uint32_t*) destination,
-                          (apr_uint32_t) newValue);
 #else
-   void* oldValue = *destination;
-   *destination = newValue;
-   return oldValue;
+   apr_atomic_xchgptr((volatile void**)destination, newValue);
 #endif
 }


Re: log4cxx-0.10.0: Fix for 64 bit-only thread safety bug in ObjectPtrBase

by Curt Arnold-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jan 16, 2009, at 11:47 AM, Rhosyn wrote:

> The attach patch fixes a thread safety issue we found with  
> ObjectPtrBase
> when we ported our application to a 64 bit platform.
>
> It will only work if you are using a version of apr with
> apr_atomic_xchgptr()
>
>
> Cheers
>

apr_atomic_xchgptr was added at our request just for this reason, but  
last I checked it hadn't made it into a released version of APR, but  
likely that has changed.  Would be good to change the configure script  
to detect whether APR has apr_atomic_xchgptr (unless you have a better  
way to detect it) and modify the code to use it if available.

Re: log4cxx-0.10.0: Fix for 64 bit-only thread safety bug in ObjectPtrBase

by abgimeno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi

I have the same problem and I could not solve. I have installed the version apache-log4cxx-0.10.0. apr-1.3.6 and apr-util-1.3.8. in a Red Hat 5 x64

I tried with the patch 596934 and does not work.

   
When the program ends gives an exception

terminate called after throwing an instance of 'log4cxx::helpers::MutexException'
  what():  Mutex exception: stat = 22
./tester.sh: line 71: 17226 Aborted                 ./tester

Rhosyn wrote:
The attach patch fixes a thread safety issue we found with ObjectPtrBase
when we ported our application to a 64 bit platform.

It will only work if you are using a version of apr with
apr_atomic_xchgptr()


Cheers



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
--- /home/rhosyn/SVN/oakx41/main/thirdparty/log4cxx/_build/app.host/app/apache-log4cxx-0.10.0/src/main/cpp/objectptr.cpp 2008-03-31 23:34:09.000000000 +0100
+++ /home/rhosyn/SVN/oakx41/main/thirdparty/log4cxx/_build/app.app/app/apache-log4cxx-0.10.0/src/main/cpp/objectptr.cpp 2009-01-07 15:39:03.000000000 +0000
@@ -36,12 +36,7 @@
 void* ObjectPtrBase::exchange(void** destination, void* newValue) {
 #if _WIN32 && (!defined(_MSC_VER) || _MSC_VER >= 1300)
     return InterlockedExchangePointer(destination, newValue);
-#elif APR_SIZEOF_VOIDP == 4
-   return (void*) apr_atomic_xchg32((volatile apr_uint32_t*) destination,
-                          (apr_uint32_t) newValue);
 #else
-   void* oldValue = *destination;
-   *destination = newValue;
-   return oldValue;
+   apr_atomic_xchgptr((volatile void**)destination, newValue);
 #endif
 }

Re: log4cxx-0.10.0: Fix for 64 bit-only thread safety bug in ObjectPtrBase

by abgimeno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I have the same problem and I could not solve. I have installed the version
apache-log4cxx-0.10.0. apr-1.3.6 and apr-util-1.3.8. in a Red Hat 5 x64

I tried with the patch 596934 and does not work.

   
When the program ends gives an exception

terminate called after throwing an instance of
'log4cxx::helpers::MutexException'
  what():  Mutex exception: stat = 22
./tester.sh: line 71: 17226 Aborted                 ./tester


Rhosyn wrote:
The attach patch fixes a thread safety issue we found with ObjectPtrBase
when we ported our application to a 64 bit platform.

It will only work if you are using a version of apr with
apr_atomic_xchgptr()


Cheers



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
--- /home/rhosyn/SVN/oakx41/main/thirdparty/log4cxx/_build/app.host/app/apache-log4cxx-0.10.0/src/main/cpp/objectptr.cpp 2008-03-31 23:34:09.000000000 +0100
+++ /home/rhosyn/SVN/oakx41/main/thirdparty/log4cxx/_build/app.app/app/apache-log4cxx-0.10.0/src/main/cpp/objectptr.cpp 2009-01-07 15:39:03.000000000 +0000
@@ -36,12 +36,7 @@
 void* ObjectPtrBase::exchange(void** destination, void* newValue) {
 #if _WIN32 && (!defined(_MSC_VER) || _MSC_VER >= 1300)
     return InterlockedExchangePointer(destination, newValue);
-#elif APR_SIZEOF_VOIDP == 4
-   return (void*) apr_atomic_xchg32((volatile apr_uint32_t*) destination,
-                          (apr_uint32_t) newValue);
 #else
-   void* oldValue = *destination;
-   *destination = newValue;
-   return oldValue;
+   apr_atomic_xchgptr((volatile void**)destination, newValue);
 #endif
 }

Re: log4cxx-0.10.0: Fix for 64 bit-only thread safety bug in ObjectPtrBase

by Curt Arnold-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 16, 2009, at 7:43 AM, abgimeno wrote:

>
> Hi
>
> I have the same problem and I could not solve. I have installed the  
> version
> apache-log4cxx-0.10.0. apr-1.3.6 and apr-util-1.3.8. in a Red Hat 5  
> x64
>
> I tried with the patch 596934 and does not work.
>
>
> When the program ends gives an exception
>
> terminate called after throwing an instance of
> 'log4cxx::helpers::MutexException'
>  what():  Mutex exception: stat = 22
> ./tester.sh: line 71: 17226 Aborted                 ./tester
>

I'l try to fire up a copy of CentOS 5 x64 this weekend.

Did it occur during the unit tests or one of the sample applications,  
or in some other context?

Re: log4cxx-0.10.0: Fix for 64 bit-only thread safety bug in ObjectPtrBase

by deepak singh-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Use  apr, apr-util, expat, log4cxx libraries compiled with -fPIC flag.
It works in my case.

On Thu, Jul 30, 2009 at 9:06 AM, Curt Arnold <carnold@...> wrote:

On Jul 16, 2009, at 7:43 AM, abgimeno wrote:


Hi

I have the same problem and I could not solve. I have installed the version
apache-log4cxx-0.10.0. apr-1.3.6 and apr-util-1.3.8. in a Red Hat 5 x64

I tried with the patch 596934 and does not work.


When the program ends gives an exception

terminate called after throwing an instance of
'log4cxx::helpers::MutexException'
 what():  Mutex exception: stat = 22
./tester.sh: line 71: 17226 Aborted                 ./tester


I'l try to fire up a copy of CentOS 5 x64 this weekend.

Did it occur during the unit tests or one of the sample applications, or in some other context?