From 1e4d1f9b29ce3d6f31cd60fa260454e3fa705919 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Jun 2006 10:35:45 +0300 Subject: [PATCH 1/2] Fixed memory leak (found by rpl_row_inexist_tbl) sql/handler.cc: Made code more portable --- sql/handler.cc | 9 +++++---- sql/log_event.cc | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index a98618172be..0dfb31fba8c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3268,10 +3268,11 @@ namespace if (thd->get_binlog_table_maps() == 0) { - MYSQL_LOCK *const locks[] = { - thd->extra_lock, thd->lock, thd->locked_tables - }; - for (my_ptrdiff_t i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i ) + MYSQL_LOCK *locks[3]; + locks[0]= thd->extra_lock; + locks[1]= thd->lock; + locks[2]= thd->locked_tables; + for (uint i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i ) { MYSQL_LOCK const *const lock= locks[i]; if (lock == NULL) diff --git a/sql/log_event.cc b/sql/log_event.cc index 05217758906..7cffa552954 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5871,7 +5871,7 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli) table_list->db, table_list->table_name); thd->query_error= 1; } - DBUG_RETURN(error); + goto err; } m_table= table_list->table; @@ -5948,7 +5948,8 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli) } thd->query_error= 1; - DBUG_RETURN(ERR_BAD_TABLE_DEF); + error= ERR_BAD_TABLE_DEF; + goto err; } /* @@ -5956,12 +5957,10 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli) locked by linking the table into the list of tables to lock, and tell the RLI that we are touching a table. */ - if (!error) - { - table_list->next_global= table_list->next_local= rli->tables_to_lock; - rli->tables_to_lock= table_list; - rli->tables_to_lock_count++; - } + table_list->next_global= table_list->next_local= rli->tables_to_lock; + rli->tables_to_lock= table_list; + rli->tables_to_lock_count++; + /* 'memory' is freed in clear_tables_to_lock */ } /* @@ -5976,7 +5975,10 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli) if (likely(!error)) rli->inc_event_relay_log_pos(); + DBUG_RETURN(error); +err: + my_free((gptr) memory, MYF(MY_WME)); DBUG_RETURN(error); } #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ From caf21245cc5c44580407919f7acef4683a7a21dd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Jun 2006 10:46:16 +0300 Subject: [PATCH 2/2] Suppress memory leak from 'kill_server' (Happens if main thread exists before kill_server thread, which is ok) --- mysql-test/valgrind.supp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index dc0f6bf1977..c30d5c8f43e 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -446,3 +446,13 @@ fun:ListAdd fun:_db_set_ } + +{ + dbug initialization by kill_server + Memcheck:Leak + fun:malloc + fun:DbugMalloc + fun:code_state + fun:_db_enter_ + fun:kill_server +}