From a743bf0b6a6acfab60660a58b57712a6bb0a0684 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 27 Oct 2017 19:15:22 +0200 Subject: [PATCH 1/2] Fix deadlock in stopAllThreads() stopAllThreads() and createThread() can deadlock (and sometimes did) because the first function takes out the threadMapMux lock and then tries to pthread_join() other threads. createThread() also tries to take out the lock but if stopAllThreads() owns it and another thread calls createThread(), then boom, the threads would deadlock each other. Drop the lock before calling pthread_join() and reacquire it afterwards. This problem was noticed on an AIX machine with Node.js Application Metrics but since the Linux port uses identical logic, I've updated that as well. The MacOS port has that code commented out but that didn't stop me from updating it anyway (but leaving it commented out.) --- src/ibmras/common/port/aix/Thread.cpp | 7 +++++-- src/ibmras/common/port/linux/Thread.cpp | 7 +++++-- src/ibmras/common/port/osx/Thread.cpp | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/ibmras/common/port/aix/Thread.cpp b/src/ibmras/common/port/aix/Thread.cpp index 3fde9b0..c77d51b 100644 --- a/src/ibmras/common/port/aix/Thread.cpp +++ b/src/ibmras/common/port/aix/Thread.cpp @@ -132,9 +132,12 @@ void stopAllThreads() { // wake currently sleeping threads condBroadcast(); while (!threadMap.empty()) { - pthread_cancel(threadMap.top()); + pthread_t top = threadMap.top(); + pthread_cancel(top); //wait for the thread to stop - pthread_join(threadMap.top(), NULL); + pthread_mutex_unlock(&threadMapMux); + pthread_join(top, NULL); + pthread_mutex_lock(&threadMapMux); threadMap.pop(); } pthread_mutex_unlock(&threadMapMux); diff --git a/src/ibmras/common/port/linux/Thread.cpp b/src/ibmras/common/port/linux/Thread.cpp index c46b3e2..f298e3e 100644 --- a/src/ibmras/common/port/linux/Thread.cpp +++ b/src/ibmras/common/port/linux/Thread.cpp @@ -130,9 +130,12 @@ void stopAllThreads() { // wake currently sleeping threads condBroadcast(); while (!threadMap.empty()) { - pthread_cancel(threadMap.top()); + pthread_t top = threadMap.top(); + pthread_cancel(top); //wait for the thread to stop - pthread_join(threadMap.top(), NULL); + pthread_mutex_unlock(&threadMapMux); + pthread_join(top, NULL); + pthread_mutex_lock(&threadMapMux); threadMap.pop(); } pthread_mutex_unlock(&threadMapMux); diff --git a/src/ibmras/common/port/osx/Thread.cpp b/src/ibmras/common/port/osx/Thread.cpp index 5da712b..9fe1915 100644 --- a/src/ibmras/common/port/osx/Thread.cpp +++ b/src/ibmras/common/port/osx/Thread.cpp @@ -143,9 +143,12 @@ void stopAllThreads() { condBroadcast(); /* while (!threadMap.empty()) { - pthread_cancel(threadMap.top()); + pthread_t top = threadMap.top(); + pthread_cancel(top); //wait for the thread to stop - pthread_join(threadMap.top(), NULL); + pthread_mutex_unlock(&threadMapMux); + pthread_join(top, NULL); + pthread_mutex_lock(&threadMapMux); threadMap.pop(); } */ From 8ad35069a77e5082bc136168bfd009b4af3b2767 Mon Sep 17 00:00:00 2001 From: Julie Stalley Date: Mon, 30 Oct 2017 13:32:21 +0000 Subject: [PATCH 2/2] Prepare for release --- README.md | 3 ++- binding.gyp | 2 +- src/ibmras/monitoring/agent/Agent.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 09d94b7..da1a459 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,10 @@ This project uses a semver-parsable X.0.Z version number for releases, where X i Non-release versions of this project (for example on github.com/RuntimeTools/omr-agentcore) will use semver-parsable X.0.Z-dev.B version numbers, where X.0.Z is the last release with Z incremented and B is an integer. For further information on the development process go to the [appmetrics wiki][3]: [Developing](https://github.com/RuntimeTools/appmetrics/wiki/Developing). ## Version -3.2.4 +3.2.5 ## Release History +`3.2.5` - Bug fixes. `3.2.4` - Node on z/OS support. `3.2.3` - Swift 4 support. `3.2.2` - Fix compiler issues on vs2010. diff --git a/binding.gyp b/binding.gyp index fd2c676..55886b3 100644 --- a/binding.gyp +++ b/binding.gyp @@ -5,7 +5,7 @@ # "externalbinariesdir%": "<(PRODUCT_DIR)/deploy/external/binaries", "externalbinariesdir%": "./plugins", 'build_id%': '.