From 9cb34778c2ddf52e5ac955822c45e2e2a432dd21 Mon Sep 17 00:00:00 2001 From: Bill Torpey Date: Fri, 12 Sep 2025 11:54:20 -0400 Subject: [PATCH 1/3] [BUS-2364] - instrument code to find problem --- common/c_cpp/src/c/thread.c | 22 +++++++++++++++++++--- mama/c_cpp/src/c/queue.c | 13 ++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/common/c_cpp/src/c/thread.c b/common/c_cpp/src/c/thread.c index 3a29221a1..c3bdd2e7f 100644 --- a/common/c_cpp/src/c/thread.c +++ b/common/c_cpp/src/c/thread.c @@ -23,6 +23,9 @@ #include #include #include +#include +#include + #include "wombat/thread.h" #include "wombat/wtable.h" @@ -41,6 +44,7 @@ typedef struct wombatThread_ { wthread_t mThread; /* Thread object (may not be defined yet). */ char* mThreadName; /* Thread name. */ + int mJoined; int mIsCpuSet; /* Has affinity been set? */ CPU_AFFINITY_SET mCpuSet; /* Affinity as defined (not necessarily as exists) */ } wombatThreadImpl; @@ -74,7 +78,7 @@ wombatThread_create( wombatThreadStatus status; if (!threadName || !wombatThread) return WOMBAT_THREAD_INVALID_ARG; - + status = allocateWombatThreadDict(); if (status != WOMBAT_THREAD_OK) return status; @@ -115,7 +119,7 @@ wombatThread_destroy (const char* name) if (!name) return WOMBAT_THREAD_INVALID_ARG; wthread_static_mutex_lock(&gWombatThreadsMutex); - + impl = wtable_lookup (gWombatThreadDict, name); /* Remove from Thread Dictionary */ @@ -130,7 +134,19 @@ wombatThread_destroy (const char* name) wthread_static_mutex_unlock(&gWombatThreadsMutex); // Attempt to join the thread to ensure it has terminated - wthread_join (impl->mThread, NULL); + //#if 0 + int result = wthread_join (impl->mThread, NULL); + fprintf(stderr, "joined thread(0x%lx), result=%d\n", impl->mThread, result); +#if 0 + void* symbols[40]; + int size = backtrace(symbols, 40); + backtrace_symbols_fd(symbols, size, STDERR_FILENO); +#endif + impl->mJoined = 1; + assert(result == 0); + + //#endif + //int result = wthread_join (impl->mThread, NULL); if (impl) { diff --git a/mama/c_cpp/src/c/queue.c b/mama/c_cpp/src/c/queue.c index ee0385198..3a78d6067 100644 --- a/mama/c_cpp/src/c/queue.c +++ b/mama/c_cpp/src/c/queue.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ +#include +#include #include "wombat/port.h" #include @@ -1399,7 +1401,16 @@ mamaDispatcher_destroy (mamaDispatcher dispatcher) } /* Wait for the thread to return. */ - wthread_join (impl->mThread, NULL); + int result = wthread_join (impl->mThread, NULL); + fprintf(stderr, "joined thread(0x%lx), result=%d\n", impl->mThread, result); + +#if 0 + void* symbols[40]; + int size = backtrace(symbols, 40); + backtrace_symbols_fd(symbols, size, STDERR_FILENO); +#endif + assert(result == 0); + wInterlocked_destroy (&impl->mIsDispatching); /* Destroy the thread handle. */ From b9ce69d1a00f862650eaa50256906e082cb22de8 Mon Sep 17 00:00:00 2001 From: Bill Torpey Date: Fri, 12 Sep 2025 14:12:48 -0400 Subject: [PATCH 2/3] [BUS-2364] - remove duplicate thread join --- common/c_cpp/src/c/thread.c | 16 +--------------- mama/c_cpp/src/c/queue.c | 14 -------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/common/c_cpp/src/c/thread.c b/common/c_cpp/src/c/thread.c index c3bdd2e7f..25c20eb01 100644 --- a/common/c_cpp/src/c/thread.c +++ b/common/c_cpp/src/c/thread.c @@ -23,8 +23,6 @@ #include #include #include -#include -#include #include "wombat/thread.h" #include "wombat/wtable.h" @@ -134,19 +132,7 @@ wombatThread_destroy (const char* name) wthread_static_mutex_unlock(&gWombatThreadsMutex); // Attempt to join the thread to ensure it has terminated - //#if 0 - int result = wthread_join (impl->mThread, NULL); - fprintf(stderr, "joined thread(0x%lx), result=%d\n", impl->mThread, result); -#if 0 - void* symbols[40]; - int size = backtrace(symbols, 40); - backtrace_symbols_fd(symbols, size, STDERR_FILENO); -#endif - impl->mJoined = 1; - assert(result == 0); - - //#endif - //int result = wthread_join (impl->mThread, NULL); + wthread_join (impl->mThread, NULL); if (impl) { diff --git a/mama/c_cpp/src/c/queue.c b/mama/c_cpp/src/c/queue.c index 3a78d6067..9c5b24312 100644 --- a/mama/c_cpp/src/c/queue.c +++ b/mama/c_cpp/src/c/queue.c @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ -#include -#include - #include "wombat/port.h" #include #include @@ -1400,17 +1397,6 @@ mamaDispatcher_destroy (mamaDispatcher dispatcher) mamaQueue_stopDispatch (impl->mQueue); } - /* Wait for the thread to return. */ - int result = wthread_join (impl->mThread, NULL); - fprintf(stderr, "joined thread(0x%lx), result=%d\n", impl->mThread, result); - -#if 0 - void* symbols[40]; - int size = backtrace(symbols, 40); - backtrace_symbols_fd(symbols, size, STDERR_FILENO); -#endif - assert(result == 0); - wInterlocked_destroy (&impl->mIsDispatching); /* Destroy the thread handle. */ From bf289c1c4d0e86b551758635e223b7c828260e5c Mon Sep 17 00:00:00 2001 From: Bill Torpey Date: Wed, 24 Sep 2025 15:24:44 -0400 Subject: [PATCH 3/3] BUS-2364] - remove duplicate thread join --- common/c_cpp/src/c/thread.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/c_cpp/src/c/thread.c b/common/c_cpp/src/c/thread.c index 25c20eb01..3a29221a1 100644 --- a/common/c_cpp/src/c/thread.c +++ b/common/c_cpp/src/c/thread.c @@ -23,7 +23,6 @@ #include #include #include - #include "wombat/thread.h" #include "wombat/wtable.h" @@ -42,7 +41,6 @@ typedef struct wombatThread_ { wthread_t mThread; /* Thread object (may not be defined yet). */ char* mThreadName; /* Thread name. */ - int mJoined; int mIsCpuSet; /* Has affinity been set? */ CPU_AFFINITY_SET mCpuSet; /* Affinity as defined (not necessarily as exists) */ } wombatThreadImpl; @@ -76,7 +74,7 @@ wombatThread_create( wombatThreadStatus status; if (!threadName || !wombatThread) return WOMBAT_THREAD_INVALID_ARG; - + status = allocateWombatThreadDict(); if (status != WOMBAT_THREAD_OK) return status; @@ -117,7 +115,7 @@ wombatThread_destroy (const char* name) if (!name) return WOMBAT_THREAD_INVALID_ARG; wthread_static_mutex_lock(&gWombatThreadsMutex); - + impl = wtable_lookup (gWombatThreadDict, name); /* Remove from Thread Dictionary */