Below is the list of changes that have just been committed into a local
5.0 repository of knielsen. When knielsen 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
1.2151 06/05/11 16:28:35 knielsen@stripped +3 -0
Fix two Valgrind memory leak warnings.
sql/mysqld.cc
1.542 06/05/11 16:28:29 knielsen@stripped +5 -0
Deallocate DBUG stack at server end, to avoid Valgrind memory leak warnings.
Add missing my_thread_end() call, seems to occasionally trigger a memory
leak (not repeatable).
include/my_dbug.h
1.17 06/05/11 16:28:29 knielsen@stripped +3 -0
Add a facility to deallocate the debug stack, to avoid memory leak warnings
in Valgrind.
dbug/dbug.c
1.22 06/05/11 16:28:29 knielsen@stripped +68 -16
Add a facility to deallocate the debug stack, to avoid memory leak warnings
in Valgrind.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: knielsen
# Host: rt.int.sifira.dk
# Root: /usr/local/mysql/mysql-5.0-vgfix
--- 1.21/dbug/dbug.c 2004-12-18 04:19:14 +01:00
+++ 1.22/dbug/dbug.c 2006-05-11 16:28:29 +02:00
@@ -271,6 +271,8 @@
static void CloseFile(FILE *fp);
/* Push current debug state */
static void PushState(void);
+ /* Free memory associated with debug state. */
+static void FreeState (struct state *state);
/* Test for tracing enabled */
static BOOLEAN DoTrace(CODE_STATE *state);
/* Test to see if file is writable */
@@ -630,22 +632,7 @@
stack = discard -> next_state;
_db_fp_ = stack -> out_file;
_db_pfp_ = stack -> prof_file;
- if (discard -> keywords != NULL) {
- FreeList (discard -> keywords);
- }
- if (discard -> functions != NULL) {
- FreeList (discard -> functions);
- }
- if (discard -> processes != NULL) {
- FreeList (discard -> processes);
- }
- if (discard -> p_functions != NULL) {
- FreeList (discard -> p_functions);
- }
- CloseFile (discard -> out_file);
- if (discard -> prof_file)
- CloseFile (discard -> prof_file);
- free ((char *) discard);
+ FreeState(discard);
if (!(stack->flags & DEBUG_ON))
_db_on_=0;
}
@@ -1158,6 +1145,71 @@
new_malloc -> processes = NULL;
new_malloc -> next_state = stack;
stack=new_malloc;
+}
+
+/*
+ * FUNCTION
+ *
+ * FreeState Free memory associated with a struct state.
+ *
+ * SYNOPSIS
+ *
+ * static void FreeState (state)
+ * struct state *state;
+ *
+ * DESCRIPTION
+ *
+ * Deallocates the memory allocated for various information in a
+ * state.
+ *
+ */
+static void FreeState (
+struct state *state)
+{
+ if (state -> keywords != NULL) {
+ FreeList (state -> keywords);
+ }
+ if (state -> functions != NULL) {
+ FreeList (state -> functions);
+ }
+ if (state -> processes != NULL) {
+ FreeList (state -> processes);
+ }
+ if (state -> p_functions != NULL) {
+ FreeList (state -> p_functions);
+ }
+ CloseFile (state -> out_file);
+ if (state -> prof_file)
+ CloseFile (state -> prof_file);
+ free ((char *) state);
+}
+
+
+/*
+ * FUNCTION
+ *
+ * _db_end_ End debugging, freeing state stack memory.
+ *
+ * SYNOPSIS
+ *
+ * static VOID _db_end_ ()
+ *
+ * DESCRIPTION
+ *
+ * Ends debugging, de-allocating the memory allocated to the
+ * state stack.
+ *
+ * To be called at the very end of the program.
+ *
+ */
+void _db_end_ ()
+{
+ reg1 struct state *discard;
+ while((discard = stack) != NULL) {
+ stack = discard -> next_state;
+ FreeState (discard);
+ }
+ _db_on_=0;
}
--- 1.16/include/my_dbug.h 2005-05-18 20:16:11 +02:00
+++ 1.17/include/my_dbug.h 2006-05-11 16:28:29 +02:00
@@ -40,6 +40,7 @@
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
uint length);
extern void _db_output_(uint flag);
+extern void _db_end_(void);
extern void _db_lock_file(void);
extern void _db_unlock_file(void);
@@ -66,6 +67,7 @@
#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
#define DEBUGGER_ON _no_db_=0
+#define DBUG_END() _db_end_ ()
#define DBUG_LOCK_FILE { _db_lock_file(); }
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
#define DBUG_OUTPUT(A) { _db_output_(A); }
@@ -90,6 +92,7 @@
#define DBUG_IN_USE 0
#define DEBUGGER_OFF
#define DEBUGGER_ON
+#define DBUG_END()
#define DBUG_LOCK_FILE
#define DBUG_UNLOCK_FILE
#define DBUG_OUTPUT(A)
--- 1.541/sql/mysqld.cc 2006-04-10 17:47:36 +02:00
+++ 1.542/sql/mysqld.cc 2006-05-11 16:28:29 +02:00
@@ -962,6 +962,10 @@
pthread_join(select_thread, NULL); // wait for main thread
#endif /* __NETWARE__ */
+#if defined(__NETWARE__) || (defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__)
&& !defined(OS2))
+ my_thread_end();
+#endif
+
pthread_exit(0); /* purecov: deadcode */
#endif /* EMBEDDED_LIBRARY */
@@ -3523,6 +3527,7 @@
wait_for_signal_thread_to_end();
clean_up_mutexes();
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
+ DBUG_END();
exit(0);
return(0); /* purecov: deadcode */
| Thread |
|---|
| • bk commit into 5.0 tree (knielsen:1.2151) | knielsen | 11 May |