[Commits] 431c796: MDEV-8738 Application Verifier stop during server shutdown

wlad at mariadb.com wlad at mariadb.com
Wed Nov 4 14:02:58 EET 2015


revision-id: 431c796fc9d10584aa1281834b8b6d8fcafdf930 (mariadb-10.1.8-18-g431c796)
parent(s): 641644a8629b9b437a1886cf19451f31a0181860
committer: Vladislav Vaintroub
timestamp: 2015-11-04 13:02:06 +0100
message:

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,
just prior to exit(), to be TLS are not used after this point.

---
 sql/mysqld.cc | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1a32f37..932bb0c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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


More information about the commits mailing list