Below is the list of changes that have just been committed into a local
5.1 repository of davi. When davi does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-02-18 10:18:07-03:00, davi@stripped +4 -0
Bug#34424 query_cache_debug.test leads to valgrind warnings
The problem is that the per-thread debugging settings stack wasn't
being deallocated before the thread termination, leaking the stack
memory. The solution is to free the per-thread debugging settings
stack once the thread finishes.
dbug/dbug.c@stripped, 2008-02-18 10:18:05-03:00, davi@stripped +43 -0
Add helper function to deallocate the per-thread code state
and associated stack.
include/my_dbug.h@stripped, 2008-02-18 10:18:05-03:00, davi@stripped +2 -0
Export function to end per-thread debugging.
mysql-test/t/disabled.def@stripped, 2008-02-18 10:18:05-03:00, davi@stripped +0 -1
Re-enable test case which triggered the leak.
mysys/my_thr_init.c@stripped, 2008-02-18 10:18:06-03:00, davi@stripped +1 -8
End (free) per-thread debugging sate.
diff -Nrup a/dbug/dbug.c b/dbug/dbug.c
--- a/dbug/dbug.c 2007-10-15 14:56:22 -02:00
+++ b/dbug/dbug.c 2008-02-18 10:18:05 -03:00
@@ -1460,6 +1460,49 @@ static void FreeState(CODE_STATE *cs, st
/*
* FUNCTION
*
+ * _db_thread_end_ End debugging, freeing state stack memory
+ * of the calling thread.
+ *
+ * SYNOPSIS
+ *
+ * VOID _db_end_ ()
+ *
+ * DESCRIPTION
+ *
+ * Ends debugging, de-allocating the memory allocated to the
+ * state stack of the current thread.
+ *
+ * To be called at the very end of the thread.
+ *
+ */
+void _db_thread_end_()
+{
+ struct settings *discard;
+ CODE_STATE *cs= NULL;
+
+ get_code_state_or_return;
+
+ while ((discard= cs->stack))
+ {
+ if (discard == &init_settings)
+ break;
+ cs->stack= discard->next;
+ FreeState(cs, discard, 1);
+ }
+
+#ifdef THREAD
+ {
+ struct st_my_thread_var *tmp= my_thread_var;
+ free(tmp->dbug);
+ tmp->dbug= NULL;
+ }
+#endif
+}
+
+
+/*
+ * FUNCTION
+ *
* _db_end_ End debugging, freeing state stack memory.
*
* SYNOPSIS
diff -Nrup a/include/my_dbug.h b/include/my_dbug.h
--- a/include/my_dbug.h 2007-10-17 15:31:49 -02:00
+++ b/include/my_dbug.h 2008-02-18 10:18:05 -03:00
@@ -75,6 +75,7 @@ extern FILE *_db_fp_(void);
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
#define DBUG_END() _db_end_ ()
+#define DBUG_THREAD_END() _db_thread_end_ ()
#define DBUG_LOCK_FILE _db_lock_file_()
#define DBUG_UNLOCK_FILE _db_unlock_file_()
#define DBUG_ASSERT(A) assert(A)
@@ -101,6 +102,7 @@ extern FILE *_db_fp_(void);
#define DBUG_LONGJMP(a1) longjmp(a1)
#define DBUG_DUMP(keyword,a1,a2)
#define DBUG_END()
+#define DBUG_THREAD_END()
#define DBUG_ASSERT(A)
#define DBUG_LOCK_FILE
#define DBUG_FILE (stderr)
diff -Nrup a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
--- a/mysql-test/t/disabled.def 2008-02-08 15:07:38 -02:00
+++ b/mysql-test/t/disabled.def 2008-02-18 10:18:05 -03:00
@@ -23,4 +23,3 @@ wait_timeout : Bug#32801 wait_ti
ctype_create : Bug#32965 main.ctype_create fails
status : Bug#32966 main.status fails
ps_ddl : Bug#12093 2007-12-14 pending WL#4165 / WL#4166
-query_cache_debug : Bug#34424: query_cache_debug.test leads to valgrind warnings
diff -Nrup a/mysys/my_thr_init.c b/mysys/my_thr_init.c
--- a/mysys/my_thr_init.c 2007-08-21 13:09:43 -03:00
+++ b/mysys/my_thr_init.c 2008-02-18 10:18:06 -03:00
@@ -328,14 +328,7 @@ void my_thread_end(void)
#endif
if (tmp && tmp->init)
{
-#if !defined(DBUG_OFF)
- /* tmp->dbug is allocated inside DBUG library */
- if (tmp->dbug)
- {
- free(tmp->dbug);
- tmp->dbug=0;
- }
-#endif
+ DBUG_THREAD_END();
#if !defined(__bsdi__) && !defined(__OpenBSD__)
/* bsdi and openbsd 3.5 dumps core here */
pthread_cond_destroy(&tmp->suspend);