List:Commits« Previous MessageNext Message »
From:Magne Mahre Date:January 19 2011 9:36am
Subject:bzr commit into mysql-trunk branch (magne.mahre:3527) Bug#58915
View as plain text  
#At file:///export/home/tmp/x/mysql-trunk-58915/ based on revid:alexander.barkov@stripped

 3527 Magne Mahre	2011-01-19
      Bug#58915 Valgrind warning in MYSQLparse()
      
      Under execution of a CHANGE MASTER command,
      a dynamic array (lex.bi.repl_ignore_server_ids)
      in the LEX replication information structure is
      allocated.
      
      Under normal operation, this array was deallocated
      at the end of execution (end of change_master() ).
      Certain error conditions (most notable if the 
      client thread is killed) would abort the execution
      before change_master() is called, resulting in
      memory block being lost.
      
      The deallocation has been moved to 
      THD::cleanup_after_query() to ensure that correct
      deallocation happens in all situations.
     @ sql/rpl_slave.cc
        Moved deallocation to THD::cleanup_after_query
     @ sql/sql_class.cc
        Moved cleanup code here (from change_master())
     @ sql/sql_lex.cc
        Initialize replication information structure
        to a known (0) value.

    modified:
      sql/rpl_slave.cc
      sql/sql_class.cc
      sql/sql_lex.cc
      sql/sql_yacc.yy
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-12-10 16:55:50 +0000
+++ b/sql/rpl_slave.cc	2011-01-19 09:36:47 +0000
@@ -6126,7 +6126,6 @@ err:
   thd_proc_info(thd, 0);
   if (ret == FALSE)
     my_ok(thd);
-  delete_dynamic(&lex_mi->repl_ignore_server_ids); //freeing of parser-time alloc
   DBUG_RETURN(ret);
 }
 

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-12-17 16:14:15 +0000
+++ b/sql/sql_class.cc	2011-01-19 09:36:47 +0000
@@ -1414,6 +1414,11 @@ void THD::cleanup_after_query()
   /* reset table map for multi-table update */
   table_map_for_update= 0;
   m_binlog_invoker= FALSE;
+  /* reset replication info structure */
+  if (lex && lex->mi.repl_ignore_server_ids.buffer) 
+  {
+    delete_dynamic(&lex->mi.repl_ignore_server_ids);
+  }
 }
 
 

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2011-01-15 05:56:24 +0000
+++ b/sql/sql_lex.cc	2011-01-19 09:36:47 +0000
@@ -2366,6 +2366,7 @@ LEX::LEX()
                          plugins_static_buffer,
                          INITIAL_LEX_PLUGIN_LIST_SIZE, 
                          INITIAL_LEX_PLUGIN_LIST_SIZE);
+  memset(&mi, 0, sizeof(LEX_MASTER_INFO));
   reset_query_tables_list(TRUE);
 }
 

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-01-10 12:45:53 +0000
+++ b/sql/sql_yacc.yy	2011-01-19 09:36:47 +0000
@@ -1874,7 +1874,7 @@ change:
             /*
               Clear LEX_MASTER_INFO struct and allocate memory for
               repl_ignore_server_ids. repl_ignore_server_ids is freed
-              at the end of change_master. So it is guaranteed to be
+              in THD::cleanup_after_query.  So it is guaranteed to be
               uninitialized before here.
             */
             lex->mi.set_unspecified();


Attachment: [text/bzr-bundle] bzr/magne.mahre@oracle.com-20110119093647-hsfa4mqfo3ruh4m2.bundle
Thread
bzr commit into mysql-trunk branch (magne.mahre:3527) Bug#58915Magne Mahre19 Jan