List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:April 9 2009 3:22pm
Subject:bzr commit into mysql-5.1-bugteam branch (davi:2867) Bug#43706 Bug#44091
View as plain text  
# At a local mysql-5.1-bugteam repository of davi

 2867 Davi Arnaut	2009-04-09
      Bug#43706: libmysqld segfaults when re-intialised
      Bug#44091: libmysqld gets stuck waiting on mutex on initialization
      
      The problem was that libmysqld wasn't enforcing a certain
      initialization and deinitialization order for the mysys
      library. Another problem was that the global object used
      for management of log event handlers (aka LOGGER) wasn't
      being prepared for a possible reutilization.
      
      What leads to the hang/crash reported is that a failure
      to load the language file triggers a double call of the
      cleanup functions, causing a already destroyed mutex to
      be used.
      
      The solution is enforce a order on the initialization and
      deinitialization of the mysys library within the libmysqld
      library and to ensure that the global LOGGER object reset
      it's internal state during cleanup.
     @ mysys/my_init.c
        Deinitialize only if initialized already.
     @ sql/log.cc
        Reset state.

    modified:
      mysys/my_init.c
      sql/log.cc
=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2009-02-05 06:16:00 +0000
+++ b/mysys/my_init.c	2009-04-09 15:22:03 +0000
@@ -136,6 +136,10 @@ void my_end(int infoflag)
   */
   FILE *info_file= DBUG_FILE;
   my_bool print_info= (info_file != stderr);
+
+  if (!my_init_done)
+    return;
+
   /*
     We do not use DBUG_ENTER here, as after cleanup DBUG is no longer
     operational, so we cannot use DBUG_RETURN.

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2009-04-08 23:42:51 +0000
+++ b/sql/log.cc	2009-04-09 15:22:03 +0000
@@ -845,6 +845,7 @@ void LOGGER::cleanup_base()
   {
     table_log_handler->cleanup();
     delete table_log_handler;
+    table_log_handler= NULL;
   }
   if (file_log_handler)
     file_log_handler->cleanup();
@@ -855,7 +856,11 @@ void LOGGER::cleanup_end()
 {
   DBUG_ASSERT(inited == 1);
   if (file_log_handler)
+  {
     delete file_log_handler;
+    file_log_handler=NULL;
+  }
+  inited= 0;
 }
 
 


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20090409152203-fu9ywx39nqam6y67.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (davi:2867) Bug#43706 Bug#44091Davi Arnaut9 Apr