Commit 1216429c authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-8738 Application Verifier stop during server shutdown

The verifier exception is caused by using thread local storage key
after key was deleted.

my_free() used current_thd within malloc size callback, which does
pthread_get_specific(THR_THD), but THR_THD is already deleted at this
point.

The fix moves pthread_key_delete() to a later point in shutdown.
parent 95289e5b
......@@ -2046,6 +2046,16 @@ extern "C" void unireg_abort(int exit_code)
mysqld_exit(exit_code);
}
static void cleanup_tls()
{
if (THR_THD)
(void)pthread_key_delete(THR_THD);
if (THR_MALLOC)
(void)pthread_key_delete(THR_MALLOC);
}
static void mysqld_exit(int exit_code)
{
DBUG_ENTER("mysqld_exit");
......@@ -2064,6 +2074,7 @@ static void mysqld_exit(int exit_code)
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
shutdown_performance_schema(); // we do it as late as possible
#endif
cleanup_tls();
DBUG_LEAVE;
sd_notify(0, "STATUS=MariaDB server is down");
exit(exit_code); /* purecov: inspected */
......@@ -2186,12 +2197,6 @@ void clean_up(bool print_message)
#endif
free_list(opt_plugin_load_list_ptr);
if (THR_THD)
(void) pthread_key_delete(THR_THD);
if (THR_MALLOC)
(void) pthread_key_delete(THR_MALLOC);
/*
The following lines may never be executed as the main thread may have
killed us
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment