From 5c9baf54e7af994391aa0510f666b364ff2e657b Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 27 Jan 2017 16:46:26 +0200 Subject: Fix for memory leak in applications, like QT,that calls my_thread_global_init() + my_thrad_global_end() repeatadily. This caused THR_KEY_mysys to be allocated multiple times. Deletion of THR_KEY_mysys was originally in my_thread_global_end() but was moved to my_end() as DBUG uses THR_KEY_mysys and DBUG is released after my_thread_global_end() is called. Releasing DBUG before my_thread_global_end() and move THR_KEY_mysys back into my_thread_global_end() could be a solution, but as safe_mutex and other things called by my_thread_global_end is using DBUG it may not be completely safe. To solve this, I used the simple solution to add a marker that THR_KEY_mysys is created and not re-create it in my_thread_global_init if it already exists. --- mysys/my_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysys/my_init.c') diff --git a/mysys/my_init.c b/mysys/my_init.c index 99efba14a73..5f6650f0ec9 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -226,7 +226,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", /* At very last, delete mysys key, it is used everywhere including DBUG */ pthread_key_delete(THR_KEY_mysys); - my_init_done=0; + my_init_done= my_thr_key_mysys_exists= 0; } /* my_end */ #ifndef DBUG_OFF -- cgit v1.2.1