From 214bd5a121058dfb31237c5326ad28b8c5f8eea3 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 9 Apr 2009 12:25:25 -0300 Subject: 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 an 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. --- sql/log.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/log.cc') diff --git a/sql/log.cc b/sql/log.cc index 44296daa939..ed2eff6625d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -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; } -- cgit v1.2.1