From: Gurucharan Shetty Date: Wed, 11 Dec 2013 23:55:03 +0000 (-0800) Subject: ovs-thread: Break recursion for coverage counters. X-Git-Tag: sliver-openvswitch-2.1.90-1~10^2~173 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0b554f5d5a37754060b24f4e31748addf9a3baf1;p=sliver-openvswitch.git ovs-thread: Break recursion for coverage counters. 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 Acked-by: Ben Pfaff --- diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h index c6a714269..1f2de72c8 100644 --- a/lib/ovs-thread.h +++ b/lib/ovs-thread.h @@ -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); \ } \