diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-10-09 18:06:22 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-10-09 18:08:12 +0100 |
commit | 00ddc8bc7c003122bc424929f2a85872dbd8b813 (patch) | |
tree | 993aaf8459fbe72db9b9952b6158e06bc0443d11 /sql/mysqld.cc | |
parent | bd21904357d95631fbbb15defe4b023dce6a24a2 (diff) | |
download | mariadb-git-00ddc8bc7c003122bc424929f2a85872dbd8b813.tar.gz |
MDEV-17413 Crash in my_malloc_size_cb_func() during shutdown with
forceful connection close.
Fix is to ensure that when close_connection() is called from shutdown
thread, current_thd is set. This that allocation callback for THD specific
memory won't assert(in debug version), or crash (in 10.1 and later)
close_connection() allocates THD specific memory e.g when it writes
the final error packet, and compression is ON for the connection.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9643f0699d1..6ac54d59ee4 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1699,7 +1699,14 @@ static void close_connections(void) tmp->thread_id, (tmp->main_security_ctx.user ? tmp->main_security_ctx.user : "")); + /* + close_connection() might need a valid current_thd + for memory allocation tracking. + */ + THD* save_thd= current_thd; + set_current_thd(tmp); close_connection(tmp,ER_SERVER_SHUTDOWN); + set_current_thd(save_thd); } #endif DBUG_PRINT("quit",("Unlocking LOCK_thread_count")); |