From c7fa9fa72b2df857dac33a76ea79d66e37918acb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 5 Feb 2013 10:43:26 +0100 Subject: [PATCH] set THR_THD key and current_thd=NULL as early as possible, otherwise safemalloc and my_malloc_size_cb_func will use current_thd before it's defined --- sql/mysqld.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 202cabaec58..c662b3279ef 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3496,6 +3496,14 @@ static int init_common_variables() umask(((~my_umask) & 0666)); my_decimal_set_zero(&decimal_zero); // set decimal_zero constant; + if (pthread_key_create(&THR_THD,NULL) || + pthread_key_create(&THR_MALLOC,NULL)) + { + sql_print_error("Can't create thread-keys"); + return 1; + } + + set_current_thd(0); set_malloc_size_cb(my_malloc_size_cb_func); tzset(); // Set tzname @@ -4038,12 +4046,6 @@ static int init_thread_environment() PTHREAD_CREATE_DETACHED); pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); - if (pthread_key_create(&THR_THD,NULL) || - pthread_key_create(&THR_MALLOC,NULL)) - { - sql_print_error("Can't create thread-keys"); - DBUG_RETURN(1); - } DBUG_RETURN(0); }