diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-08-20 10:32:04 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-08-20 10:32:04 +0300 |
commit | 7b4de10477a7bdb51656d827ad2d914d29a4be4c (patch) | |
tree | bf1bade9ffc78d908539de4832c2800369375f85 /sql/wsrep_thd.cc | |
parent | c5bc0cedea01cabfcd3a8d0d1410e427e2edc08e (diff) | |
download | mariadb-git-7b4de10477a7bdb51656d827ad2d914d29a4be4c.tar.gz |
MDEV-20378: Galera uses uninitialized memory
Problem was that wsrep thread argument was deleted on wrong
place. Furthermore, scan method incorrectly used unsafe c_ptr().
Finally, fixed wsrep thread initialization to correctly set
up thread_id and pass correct argument to functions and
fix signess problem causing compiler errors.
Diffstat (limited to 'sql/wsrep_thd.cc')
-rw-r--r-- | sql/wsrep_thd.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 5907d495ee9..659bb8545b2 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -86,7 +86,7 @@ static void wsrep_replication_process(THD *thd, static bool create_wsrep_THD(Wsrep_thd_args* args) { ulong old_wsrep_running_threads= wsrep_running_threads; - pthread_t unused; + #ifdef HAVE_PSI_THREAD_INTERFACE PSI_thread_key key; @@ -103,7 +103,7 @@ static bool create_wsrep_THD(Wsrep_thd_args* args) break; } #endif - bool res= mysql_thread_create(key, &unused, &connection_attrib, + bool res= mysql_thread_create(key, args->thread_id(), &connection_attrib, start_wsrep_THD, (void*)args); /* if starting a thread on server startup, wait until the this thread's THD @@ -123,9 +123,9 @@ void wsrep_create_appliers(long threads) /* Dont' start slave threads if wsrep-provider or wsrep-cluster-address is not set. */ - if (!WSREP_PROVIDER_EXISTS) + if (!WSREP_PROVIDER_EXISTS) { - return; + return; } if (!wsrep_cluster_address || wsrep_cluster_address[0]== 0) @@ -135,11 +135,12 @@ void wsrep_create_appliers(long threads) } long wsrep_threads=0; - + while (wsrep_threads++ < threads) { - Wsrep_thd_args* args(new Wsrep_thd_args(wsrep_replication_process, 0, - WSREP_APPLIER_THREAD)); + Wsrep_thd_args* args(new Wsrep_thd_args(wsrep_replication_process, + WSREP_APPLIER_THREAD, + pthread_self())); if (create_wsrep_THD(args)) { WSREP_WARN("Can't create thread to manage wsrep replication"); @@ -328,16 +329,19 @@ void wsrep_create_rollbacker() { if (wsrep_cluster_address && wsrep_cluster_address[0] != 0) { - Wsrep_thd_args* args= new Wsrep_thd_args(wsrep_rollback_process, 0, - WSREP_ROLLBACKER_THREAD); + Wsrep_thd_args* args(new Wsrep_thd_args(wsrep_rollback_process, + WSREP_ROLLBACKER_THREAD, + pthread_self())); /* create rollbacker */ if (create_wsrep_THD(args)) WSREP_WARN("Can't create thread to manage wsrep rollback"); /* create post_rollbacker */ - args= new Wsrep_thd_args(wsrep_post_rollback_process, 0, - WSREP_ROLLBACKER_THREAD); + args= new Wsrep_thd_args(wsrep_post_rollback_process, + WSREP_ROLLBACKER_THREAD, + pthread_self()); + if (create_wsrep_THD(args)) WSREP_WARN("Can't create thread to manage wsrep post rollback"); } |