Commit c20c135a authored by Venkata Sidagam's avatar Venkata Sidagam

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.
parent cd4fb2ae
...@@ -1242,6 +1242,16 @@ int main(int argc,char *argv[]) ...@@ -1242,6 +1242,16 @@ int main(int argc,char *argv[])
sig_handler mysql_end(int sig) 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); mysql_close(&mysql);
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
if (!status.batch && !quick && !opt_html && !opt_xml && if (!status.batch && !quick && !opt_html && !opt_xml &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment