[prev in list] [next in list] [prev in thread] [next in thread]
List: log4cxx-user
Subject: log4cxx 0.9.7: Fix for memory leaks and crashes in x86_64 builds
From: "RUOFF, LARS (LARS)" <lars.ruoff () alcatel-lucent ! com>
Date: 2014-10-21 11:25:05
Message-ID: 961FAF1FA8C67741A2A78C3B0890784E01CBFE6B () FR712WXCHMBA12 ! zeu ! alcatel-lucent ! com
[Download RAW message or body]
Hi,
For those who like I are stuck with log4cxx v0.9.7 and have experienced memory leaks \
and crashes in x86_64 (64bit) builds on Linux, Here is a small fix:
(Base is 0.9.7)
src\thread.cpp:
@@ -201,6 +201,14 @@
: "0" (1), "m" (*val));
return ret+1;
+#elif defined(__x86_64__)
+ long ret;
+
+ __asm__ __volatile__ ("lock; xadd %0, %1"
+ : "=r" (ret), "=m" (*val)
+ : "0" (1), "m" (*val));
+
+ return ret+1;
#elif defined(sparc) && defined(__SUNPRO_CC)
sparc_atomic_add_32(val, 1);
return *val;
@@ -226,6 +234,14 @@
: "0" (-1), "m" (*val));
return ret-1;
+#elif defined(__x86_64__)
+ long ret;
+
+ __asm__ __volatile__ ("lock; xadd %0, %1"
+ : "=r" (ret), "=m" (*val)
+ : "0" (-1), "m" (*val));
+
+ return ret-1;
#elif defined(sparc) && defined(__SUNPRO_CC)
sparc_atomic_add_32(val, -1);
The problem was that the locked increment/decrement functions (used by the reference \
counting for smart pointers for all of log4cxx's dynamic objects) had empty function \
bodies on x86_64 systems.
Note: The latest 0.10.x versions probably don't have this issue as they are relying \
on Apache libs for locked increment.
hope it can be usefull,
Best regards,
Lars Ruoff
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic