Bug #29469 Client dies if a query is issued after hitting Ctrl + C
Submitted: 1 Jul 2007 13:50 Modified: 25 Jul 2007 3:43
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:5.0.44-enterprise-gpl-nt OS:Windows (2000, XP)
Assigned to: Georgi Kodinov CPU Architecture:Any
Tags: qc

[1 Jul 2007 13:50] Philip Stoev
Description:
IF you hit Ctrl+C within the mysql client and then issue a query and hit return, the client will misbehave and die.

How to repeat:
C:\Documents and Settings\Administrator>mysql -uproc
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.0.44-enterprise-gpl-nt MySQL Enterprise Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

--- We hit Ctrl + C

mysql> Aborted
mysql>

--- We issue SELECT 1

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 1045 (28000): Access denied for user 'utf8'@'localhost' (using password: NO)
ERROR:
Can't connect to the server

mysql>

--- We hit Return

mysql> Error in my_thread_global_end(): 1 threads didn't exit

Suggested fix:
Note that the second connection attempt is made from a username of utf8, which does not make sense. Sometimes the username can even be 'mysql> ', so it appears that there is a buffer corruption somewhere.
[2 Jul 2007 8:48] Valeriy Kravchuk
Thank you for a bug report. Verified just as described on XP:

C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot test -P3308
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.44-enterprise-gpl-nt MySQL Enterprise Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

mysql> Aborted
mysql> select 1;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 1045 (28000): Access denied for user '┬и☺)'@'localhost' (using password: Y
ES)
ERROR:
Can't connect to the server

Xї)Error in my_thread_global_end(): 1 threads didn't exit

C:\Program Files\MySQL\MySQL Server 5.0\bin>
[9 Jul 2007 14:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/30533

ChangeSet@1.2525, 2007-07-09 17:53:52+03:00, gkodinov@magare.gmz +2 -0
  Bug #29469: Client dies if a query is issued after hitting Ctrl + C
  The Ctrl-C handler in mysql closes the console while ReadConsole()
  waits for console input.
  But the main thread was detecting that ReadConsole() haven't read 
  anything and was processing as if there're data in the buffer.
  Fixed to handle correctly this error condition.
  No test case added as the test relies on Ctrl-C sent to the client
  from its console.
[9 Jul 2007 15:12] Georgi Kodinov
bug #29468 marked as a duplicate of this one.
[9 Jul 2007 22:02] Reggie Burnett
Assuming this has been thoroughly tested and solves the problem, I have no problem with it.
[10 Jul 2007 7:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/30587

ChangeSet@1.2525, 2007-07-10 10:43:12+03:00, gkodinov@magare.gmz +2 -0
  Bug #29469: Client dies if a query is issued after hitting Ctrl + C
  The Ctrl-C handler in mysql closes the console while ReadConsole()
  waits for console input.
  But the main thread was detecting that ReadConsole() haven't read 
  anything and was processing as if there're data in the buffer.
  Fixed to handle correctly this error condition.
  No test case added as the test relies on Ctrl-C sent to the client
  from its console.
[20 Jul 2007 23:46] Bugs System
Pushed into 5.1.21-beta
[20 Jul 2007 23:49] Bugs System
Pushed into 5.0.48
[25 Jul 2007 3:43] Paul DuBois
Noted in 5.0.48, 5.1.21 changelogs.

On Windows, the mysql client died if the user entered a
statement and Return after entering Control-C.