[ovs-dev] [PATCH] ovs-thread: Break recursion for coverage counters.

Gurucharan Shetty shettyg at nicira.com
Thu Dec 12 00:11:24 UTC 2013


For systems that do not use linker sections and also do not
have either HAVE_THREAD_LOCAL or HAVE___THREAD (ex: windows
using MSVC), a COVERAGE_INC() calls xmalloc which inturn calls
COVERAGE_INC() creating a recursion that causes a stack overflow.

This commit breaks the recursion by calling malloc() instead of
xmalloc()

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 lib/ovs-thread.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h
index 7f3195d..8de0f27 100644
--- a/lib/ovs-thread.h
+++ b/lib/ovs-thread.h
@@ -313,7 +313,10 @@ void xpthread_join(pthread_t, void **);
         if (!value) {                                                   \
             static const NAME##_type initial_value = __VA_ARGS__;       \
                                                                         \
-            value = xmalloc(sizeof *value);                             \
+            value = malloc(sizeof *value);                              \
+            if (value == NULL) {                                        \
+                out_of_memory();                                        \
+            }                                                           \
             *value = initial_value;                                     \
             xpthread_setspecific(NAME##_key, value);                    \
         }                                                               \
-- 
1.7.9.5




More information about the dev mailing list