Bug #17297324 GLIBC DOUBLE FREE OR CORRUPTION WHEN KILLING CLIENT; CTRL+C

Description: Sometimes when killing the mysql command line client with
KILL -2(SIGINT), mysql client core dumps as a result of a double free or
corruption.

Analysis: When we run the mysql client in command line mode it will goes
to mysql_end() and frees many data structures. At the same time (i.e
after some data structures are freed), if we give "KILL -2" signal then
the signal will be handled with function handle_kill_signal() and as
part of it will again calls mysql_end() and goes with free() to the
already freed data structure for batch_readline_end() function, which
causes core dump.

Fix: Ignoring SIGQUIT and SIGINT signals when cleanup process starts.
This will help in resolving the double free issues, which occurs 
in case the signal handler function is started in between of the 
clean up function.
For 5.6 we need to ignore SIGHUP also.
This commit is contained in:
Venkata Sidagam 2014-07-21 11:26:50 +05:30
parent cd4fb2aeae
commit c20c135a23

View file

@ -1242,6 +1242,16 @@ int main(int argc,char *argv[])
sig_handler mysql_end(int sig)
{
#ifndef _WIN32
/*
Ingnoring SIGQUIT and SIGINT signals when cleanup process starts.
This will help in resolving the double free issues, which occures in case
the signal handler function is started in between the clean up function.
*/
signal(SIGQUIT, SIG_IGN);
signal(SIGINT, SIG_IGN);
#endif
mysql_close(&mysql);
#ifdef HAVE_READLINE
if (!status.batch && !quick && !opt_html && !opt_xml &&