summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2017-10-06 12:46:12 +0300
committerSergey Vojtovich <svoj@mariadb.org>2017-10-06 13:46:12 +0400
commite59d080ffa233edeffdfe860444874e748289563 (patch)
treedce3ad209c28f5c76d212bf1bb0ac53fc708c512
parenta4948dafcd7eee65f16d848bdc6562fc49ef8916 (diff)
downloadmariadb-git-e59d080ffa233edeffdfe860444874e748289563.tar.gz
fix a data race in debug build (#456)
fix a data race in debug build This particular one flooded TSAN report.
-rw-r--r--storage/innobase/include/sync0policy.h12
-rw-r--r--storage/innobase/include/sync0policy.ic2
-rw-r--r--storage/innobase/include/sync0types.h2
3 files changed, 9 insertions, 7 deletions
diff --git a/storage/innobase/include/sync0policy.h b/storage/innobase/include/sync0policy.h
index 1b86d2633bf..6d485c30aed 100644
--- a/storage/innobase/include/sync0policy.h
+++ b/storage/innobase/include/sync0policy.h
@@ -76,7 +76,7 @@ public:
{
m_mutex = mutex;
- m_thread_id = os_thread_get_curr_id();
+ my_atomic_storelint(&m_thread_id, os_thread_get_curr_id());
m_filename = filename;
@@ -89,7 +89,7 @@ public:
{
m_mutex = NULL;
- m_thread_id = os_thread_id_t(ULINT_UNDEFINED);
+ my_atomic_storelint(&m_thread_id, ULINT_UNDEFINED);
m_filename = NULL;
@@ -138,7 +138,7 @@ public:
unsigned m_line;
/** Thread ID of the thread that own(ed) the mutex */
- os_thread_id_t m_thread_id;
+ ulint m_thread_id;
};
/** Constructor. */
@@ -157,7 +157,7 @@ public:
/** Mutex is being destroyed. */
void destroy() UNIV_NOTHROW
{
- ut_ad(m_context.m_thread_id == os_thread_id_t(ULINT_UNDEFINED));
+ ut_ad((ulint)my_atomic_loadlint(&m_context.m_thread_id) == ULINT_UNDEFINED);
m_magic_n = 0;
@@ -199,7 +199,7 @@ public:
bool is_owned() const UNIV_NOTHROW
{
return(os_thread_eq(
- m_context.m_thread_id,
+ my_atomic_loadlint(&m_context.m_thread_id),
os_thread_get_curr_id()));
}
@@ -221,7 +221,7 @@ public:
os_thread_id_t get_thread_id() const
UNIV_NOTHROW
{
- return(m_context.m_thread_id);
+ return(my_atomic_loadlint(&m_context.m_thread_id));
}
/** Magic number to check for memory corruption. */
diff --git a/storage/innobase/include/sync0policy.ic b/storage/innobase/include/sync0policy.ic
index f3526bbfef5..2e032a51fb8 100644
--- a/storage/innobase/include/sync0policy.ic
+++ b/storage/innobase/include/sync0policy.ic
@@ -80,7 +80,7 @@ void MutexDebug<Mutex>::locked(
UNIV_NOTHROW
{
ut_ad(!is_owned());
- ut_ad(m_context.m_thread_id == os_thread_id_t(ULINT_UNDEFINED));
+ ut_ad(m_context.m_thread_id == ULINT_UNDEFINED);
m_context.locked(mutex, name, line);
diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h
index 194fa50e2fe..0c1c9adee45 100644
--- a/storage/innobase/include/sync0types.h
+++ b/storage/innobase/include/sync0types.h
@@ -1163,10 +1163,12 @@ enum rw_lock_flag_t {
#ifdef _WIN64
#define my_atomic_addlint(A,B) my_atomic_add64((int64*) (A), (B))
#define my_atomic_loadlint(A) my_atomic_load64((int64*) (A))
+#define my_atomic_storelint(A,B) my_atomic_store64((int64*) (A), (B))
#define my_atomic_caslint(A,B,C) my_atomic_cas64((int64*) (A), (int64*) (B), (C))
#else
#define my_atomic_addlint my_atomic_addlong
#define my_atomic_loadlint my_atomic_loadlong
+#define my_atomic_storelint my_atomic_storelong
#define my_atomic_caslint my_atomic_caslong
#endif