mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
don't let current_thd to point to a destroyed THD
* reset current_thd in THD::~THD, otherwise my_malloc_size_cb_func() might access THD after it was destroyed. * remove now redundant set_current_thd(0) calls that follow delete thd.
This commit is contained in:
@ -896,8 +896,6 @@ end:
|
|||||||
delete scheduler;
|
delete scheduler;
|
||||||
}
|
}
|
||||||
delete thd;
|
delete thd;
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
|
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
@ -2973,8 +2973,6 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
|
|||||||
const bool wsrep_applier= IF_WSREP(thd->wsrep_applier, false);
|
const bool wsrep_applier= IF_WSREP(thd->wsrep_applier, false);
|
||||||
|
|
||||||
unlink_thd(thd);
|
unlink_thd(thd);
|
||||||
/* Mark that current_thd is not valid anymore */
|
|
||||||
set_current_thd(0);
|
|
||||||
|
|
||||||
if (put_in_cache && cache_thread() && !wsrep_applier)
|
if (put_in_cache && cache_thread() && !wsrep_applier)
|
||||||
DBUG_RETURN(0); // Thread is reused
|
DBUG_RETURN(0); // Thread is reused
|
||||||
@ -6555,7 +6553,6 @@ void handle_connections_sockets()
|
|||||||
(void) mysql_socket_close(new_sock);
|
(void) mysql_socket_close(new_sock);
|
||||||
}
|
}
|
||||||
delete thd;
|
delete thd;
|
||||||
set_current_thd(0);
|
|
||||||
statistic_increment(connection_errors_internal, &LOCK_status);
|
statistic_increment(connection_errors_internal, &LOCK_status);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -6670,7 +6667,6 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
|
|||||||
{
|
{
|
||||||
close_connection(thd, ER_OUT_OF_RESOURCES);
|
close_connection(thd, ER_OUT_OF_RESOURCES);
|
||||||
delete thd;
|
delete thd;
|
||||||
set_current_thd(0);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Host is unknown */
|
/* Host is unknown */
|
||||||
|
@ -1140,8 +1140,6 @@ bool acl_init(bool dont_read_acl_tables)
|
|||||||
*/
|
*/
|
||||||
return_val= acl_reload(thd);
|
return_val= acl_reload(thd);
|
||||||
delete thd;
|
delete thd;
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
DBUG_RETURN(return_val);
|
DBUG_RETURN(return_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6556,8 +6554,6 @@ bool grant_init()
|
|||||||
thd->store_globals();
|
thd->store_globals();
|
||||||
return_val= grant_reload(thd);
|
return_val= grant_reload(thd);
|
||||||
delete thd;
|
delete thd;
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
DBUG_RETURN(return_val);
|
DBUG_RETURN(return_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9024,7 +9024,6 @@ my_bool mysql_rm_tmp_tables(void)
|
|||||||
my_dirend(dirp);
|
my_dirend(dirp);
|
||||||
}
|
}
|
||||||
delete thd;
|
delete thd;
|
||||||
set_current_thd(0);
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1712,7 +1712,7 @@ THD::~THD()
|
|||||||
DBUG_ASSERT(status_var.local_memory_used == 0);
|
DBUG_ASSERT(status_var.local_memory_used == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_current_thd(orig_thd);
|
set_current_thd(orig_thd == this ? 0 : orig_thd);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1775,7 +1775,6 @@ static void plugin_load(MEM_ROOT *tmp_root)
|
|||||||
end:
|
end:
|
||||||
/* Remember that we don't have a THD */
|
/* Remember that we don't have a THD */
|
||||||
delete new_thd;
|
delete new_thd;
|
||||||
set_current_thd(0);
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +98,6 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
|
|||||||
if (tmp_thd)
|
if (tmp_thd)
|
||||||
{
|
{
|
||||||
delete tmp_thd;
|
delete tmp_thd;
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
thd= 0;
|
thd= 0;
|
||||||
}
|
}
|
||||||
reset_mqh((LEX_USER *)NULL, TRUE);
|
reset_mqh((LEX_USER *)NULL, TRUE);
|
||||||
|
@ -173,8 +173,6 @@ bool servers_init(bool dont_read_servers_table)
|
|||||||
*/
|
*/
|
||||||
return_val= servers_reload(thd);
|
return_val= servers_reload(thd);
|
||||||
delete thd;
|
delete thd;
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
DBUG_RETURN(return_val);
|
DBUG_RETURN(return_val);
|
||||||
|
@ -1674,8 +1674,6 @@ void execute_ddl_log_recovery()
|
|||||||
global_ddl_log.recovery_phase= FALSE;
|
global_ddl_log.recovery_phase= FALSE;
|
||||||
mysql_mutex_unlock(&LOCK_gdl);
|
mysql_mutex_unlock(&LOCK_gdl);
|
||||||
delete thd;
|
delete thd;
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +258,6 @@ void udf_init()
|
|||||||
end:
|
end:
|
||||||
close_mysql_tables(new_thd);
|
close_mysql_tables(new_thd);
|
||||||
delete new_thd;
|
delete new_thd;
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1803,11 +1803,7 @@ end:
|
|||||||
if (org_thd)
|
if (org_thd)
|
||||||
org_thd->store_globals(); /* purecov: inspected */
|
org_thd->store_globals(); /* purecov: inspected */
|
||||||
else
|
else
|
||||||
{
|
|
||||||
/* Remember that we don't have a THD */
|
|
||||||
set_current_thd(0);
|
|
||||||
my_pthread_setspecific_ptr(THR_MALLOC, 0);
|
my_pthread_setspecific_ptr(THR_MALLOC, 0);
|
||||||
}
|
|
||||||
|
|
||||||
default_tz= default_tz_name ? global_system_variables.time_zone
|
default_tz= default_tz_name ? global_system_variables.time_zone
|
||||||
: my_tz_SYSTEM;
|
: my_tz_SYSTEM;
|
||||||
|
Reference in New Issue
Block a user