ovs-thread: Break recursion for coverage counters.
authorGurucharan Shetty <gshetty@nicira.com>
Wed, 11 Dec 2013 23:55:03 +0000 (15:55 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Fri, 13 Dec 2013 18:57:19 +0000 (10:57 -0800)
For systems that 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@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/ovs-thread.h

index c6a7142..1f2de72 100644 (file)
@@ -276,7 +276,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);                    \
         }                                                               \
@@ -313,7 +316,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);                    \
         }                                                               \