summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2016-03-31 15:09:29 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2016-03-31 15:09:29 -0400
commita96f4e5703a0490c14c09b1a2c9ab5a2ba8d3940 (patch)
tree4de568d0ea38cf5df7b40178e060bbe78d019f47
parent869912de45bfec53f8fd15c4f716b49ac2ca7aa4 (diff)
downloadmongo-a96f4e5703a0490c14c09b1a2c9ab5a2ba8d3940.tar.gz
SERVER-17294 Boost 1.60 Compilation fix & ASAN leak fix
-rw-r--r--src/third_party/boost-1.60.0/boost/thread/pthread/condition_variable_fwd.hpp5
-rw-r--r--src/third_party/boost-1.60.0/libs/thread/src/pthread/thread.cpp17
2 files changed, 22 insertions, 0 deletions
diff --git a/src/third_party/boost-1.60.0/boost/thread/pthread/condition_variable_fwd.hpp b/src/third_party/boost-1.60.0/boost/thread/pthread/condition_variable_fwd.hpp
index 1255eac59b7..2086eddff7e 100644
--- a/src/third_party/boost-1.60.0/boost/thread/pthread/condition_variable_fwd.hpp
+++ b/src/third_party/boost-1.60.0/boost/thread/pthread/condition_variable_fwd.hpp
@@ -81,7 +81,12 @@ namespace boost
{
boost::throw_exception(thread_resource_error(res, "boost::condition_variable::condition_variable() constructor failed in pthread_mutex_init"));
}
+#else
+ // MONGODB MODIFICATION
+ // See https://svn.boost.org/trac/boost/ticket/12102
+ int res;
#endif
+
res = detail::monotonic_pthread_cond_init(cond);
if (res)
{
diff --git a/src/third_party/boost-1.60.0/libs/thread/src/pthread/thread.cpp b/src/third_party/boost-1.60.0/libs/thread/src/pthread/thread.cpp
index 969e58cc5dc..441a47f1dec 100644
--- a/src/third_party/boost-1.60.0/libs/thread/src/pthread/thread.cpp
+++ b/src/third_party/boost-1.60.0/libs/thread/src/pthread/thread.cpp
@@ -115,6 +115,22 @@ namespace boost
}
}
+#if defined BOOST_THREAD_PATCH
+// MONGODB Modification - revert to Boost 1.59 behavior, and do not delete TLS keys.
+// This prevents ASAN leaks in unit tests by giving us a chance to free the TLS slots on the main
+// thread.
+//
+// Here is how the leak works:
+// 1. create_current_thread_tls_key allocates a pthread key.
+// 2. during process shutdown, libc calls atexit handlers.
+// a. delete_current_thread_tls_key_on_dlclose_t::~ delete_current_thread_tls_key_on_dlclose_t
+// is called, and deletes the pthread key.
+// b. thread_specific_ptr::~thread_specific_ptr is called which calls set_tss_data, and this
+// uses the pthread key to get the actual data to destroy. Since the pthread key has been
+// deallocated, pthread_getspecific returns null, and memory is leaked.
+//
+// See https://github.com/boostorg/thread/blob/boost-1.59.0/src/pthread/thread.cpp#L118-L134
+// and https://github.com/boostorg/thread/commit/242cf35c519fc886c13789f1f9a049571fde4cdc#diff-d70e9675395ed66968d044fcfaa862b7
struct delete_current_thread_tls_key_on_dlclose_t
{
delete_current_thread_tls_key_on_dlclose_t()
@@ -130,6 +146,7 @@ namespace boost
}
};
delete_current_thread_tls_key_on_dlclose_t delete_current_thread_tls_key_on_dlclose;
+#endif
void create_current_thread_tls_key()
{