Bug #26892 mysql client crash after pressing ctrl-c
Submitted: 6 Mar 2007 20:13 Modified: 1 Feb 2008 17:17
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0.34, 5.0.38, 5.1.16-win64, 5.1.23 OS:Windows (windows XP 64-bit)
Assigned to: Iggy Galarza CPU Architecture:Any

[6 Mar 2007 20:13] Shane Bester
Description:
when pressing control-c the client can crash on windows.

crash in bug #17926 seems in a different place in the code to this bug, and this testcase is different (simpler) so I filed a new bug report

the crash in debug build is slightly different, but the cause is likely the same: some illegally referenced memory.  Notice the printed out 'YYYYYYYYYYYYYYYY' in the below test. Second test is crash.

Debug build crash:
-------------------
mysql.exe!DoTrace
mysql.exe!_db_enter_
mysql.exe!_mymalloc
mysql.exe!String::realloc
mysql.exe!String::c_ptr
mysql.exe!read_and_execute
mysql.exe!main
mysql.exe!__tmainCRTStartup
mysql.exe!mainCRTStartup
kernel32.dll!BaseProcessInitPostImport

Release build crash:
--------------------
ntdll.dll!RtlUnicodeToMultiByteSize
ntdll.dll!RtlUnicodeToMultiByteSize
mysql.exe!free
mysql.exe!mysql_end
mysql.exe!main
mysql.exe!__tmainCRTStartup
kernel32.dll!BaseProcessInitPostImport

How to repeat:
Simply run the client, then ctrl-c, and exit.

C:\build\mysql-5.0.38-win-src\mysql-5.0.38\client_debug>mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.38 yes

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

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

C:\build\mysql-5.0.38-win-src\mysql-5.0.38\client_debug>mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.38 yes

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

mysql> Aborted

Suggested fix:
.
[6 Mar 2007 20:14] MySQL Verification Team
stack with variables.

Attachment: bug26892_stack.txt (text/plain), 1.50 KiB.

[7 Mar 2007 8:25] Sveta Smirnova
Bug is not repeatable on 32-bit Windows XP
[9 Mar 2007 12:37] Valeriy Kravchuk
Official 5.1.16 also does not demonstrate the behaviour described on 64-bit XP.
[9 Mar 2007 14:01] MySQL Verification Team
verified on official mysql 5.1.16 win64 noinstall package.
simply run client, "mysql -uroot test"
then hit ctrl-c.

I can give a screenshot if needed

mysql.exe!0000000000432b23() 	
[Frames below may be incorrect and/or missing, no symbols loaded for mysql.exe]	
mysql.exe!0000000000409d52() 	
mysql.exe!000000000040ace2() 	
mysql.exe!000000000046c11f() 	
kernel32.dll!BaseProcessStart()  + 0x2c bytes	

this should be fixable by looking at the stack traces i provided initially.
also, i doubt this is 64-bit specific
[4 Nov 2007 17:37] MySQL Verification Team
5.1.23BK debug client crashes if you press ctrl-c.

Error: Freeing unallocated data at line 535, '.\mysql.cc'
Error: Freeing unallocated data at line 536, '.\mysql.cc'
Error: Freeing unallocated data at line 537, '.\mysql.cc'
Error: Freeing unallocated data at line 540, '.\mysql.cc'
Error: Freeing unallocated data at line 544, '.\mysql.cc'

I noticed mysql_end() is called twice.  The second call to free_defaults(defaults_argv); crashes because there is garbage pointer being deferenced.
[4 Jan 2008 13:50] Valeriy Kravchuk
Is it a duplicate of Bug #26243?