diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-10-09 18:34:37 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-10-09 18:44:10 +0100 |
commit | 5b0b6660f6010dbd9fe8807af72ddba4d9b73781 (patch) | |
tree | 8524fbd96684d08a0c247a9beeed6152f9ca3c9f /sql/mysqld.cc | |
parent | f517d8c7425257b6b9fe81c82c489e1e5619898d (diff) | |
download | mariadb-git-5b0b6660f6010dbd9fe8807af72ddba4d9b73781.tar.gz |
MDEV-17413 - Don't crash in my_malloc_size_cb_func()
if thread specific memory is requested and current_thd is NULL.
Leave DBUG_ASSERT() in place, to check in DBUG version.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3dff49f5ccb..c2fdb5a4026 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3907,14 +3907,16 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) { THD *thd= current_thd; - if (is_thread_specific) /* If thread specific memory */ - { - /* - When thread specfic is set, both mysqld_server_initialized and thd - must be set - */ - DBUG_ASSERT(mysqld_server_initialized && thd); + /* + When thread specific is set, both mysqld_server_initialized and thd + must be set, and we check that with DBUG_ASSERT. + However, do not crash, if current_thd is NULL, in release version. + */ + DBUG_ASSERT(!is_thread_specific || (mysqld_server_initialized && thd)); + + if (is_thread_specific && likely(thd)) /* If thread specific memory */ + { DBUG_PRINT("info", ("thd memory_used: %lld size: %lld", (longlong) thd->status_var.local_memory_used, size)); |