From 0357791e3c291c47fe128954dac45c271f721b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Mon, 22 Jun 2015 08:44:46 +0300 Subject: [PATCH] MDEV-8280: crash in 'show global status' with --skip-grant-tables The crash was caused by attempting to use a hashtable without it getting initialized, due to the --skip-grant-tables switch. --- mysql-test/r/skip_grants.result | 11 +++++++++++ mysql-test/t/skip_grants.test | 5 +++++ sql/sql_acl.cc | 13 ++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/skip_grants.result b/mysql-test/r/skip_grants.result index b178e0ecfa7..db3b6abdc8b 100644 --- a/mysql-test/r/skip_grants.result +++ b/mysql-test/r/skip_grants.result @@ -80,3 +80,14 @@ End of 5.0 tests select no_such_function(1); ERROR 42000: FUNCTION test.no_such_function does not exist End of 5.1 tests +show global status like 'Acl%'; +Variable_name Value +Acl_column_grants 0 +Acl_database_grants 0 +Acl_function_grants 0 +Acl_procedure_grants 0 +Acl_proxy_users 0 +Acl_role_grants 0 +Acl_roles 0 +Acl_table_grants 0 +Acl_users 0 diff --git a/mysql-test/t/skip_grants.test b/mysql-test/t/skip_grants.test index 6f4d23e1e14..2dc64254a9a 100644 --- a/mysql-test/t/skip_grants.test +++ b/mysql-test/t/skip_grants.test @@ -132,3 +132,8 @@ select count(*) from information_schema.USER_PRIVILEGES; select no_such_function(1); --echo End of 5.1 tests + +# +# MDEV-8280 crash in 'show global status' with --skip-grant-tables +# +show global status like 'Acl%'; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1e94e75cf75..ad0c3976070 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10383,11 +10383,14 @@ static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff, var->type= SHOW_ULONG; var->value= buff; *(ulong *)buff= 0; - mysql_rwlock_rdlock(&LOCK_grant); - mysql_mutex_lock(&acl_cache->lock); - my_hash_iterate(&column_priv_hash, count_column_grants, buff); - mysql_mutex_unlock(&acl_cache->lock); - mysql_rwlock_unlock(&LOCK_grant); + if (initialized) + { + mysql_rwlock_rdlock(&LOCK_grant); + mysql_mutex_lock(&acl_cache->lock); + my_hash_iterate(&column_priv_hash, count_column_grants, buff); + mysql_mutex_unlock(&acl_cache->lock); + mysql_rwlock_unlock(&LOCK_grant); + } return 0; }