Bug #26243 mysql command line crash after control-c
Submitted: 9 Feb 2007 23:53 Modified: 7 Apr 2008 17:24
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0.36 OS:Windows (windows)
Assigned to: Iggy Galarza CPU Architecture:Any

[9 Feb 2007 23:53] Shane Bester
Description:
the debug version of the command line client still crashes sometimes when pressing control-c.

It crashes after "Aborted" is printed.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 206
Server version: 5.0.36-debug yes

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

mysql> Aborted
<crash>

Stack trace:
!DoTrace(st_code_state * state=0x01e626d0)  Line 1242 + 0x5 bytes	C
!_db_enter_(const char * _func_=0x005390f0, const char * _file_=0x005390e0, unsigned int _line_=126, const char * * _sfunc_=0x002dfdfc, const char * * _sfile_=0x002dfe0c, unsigned int * _slevel_=0x002dfe00, char * * * _sframep_=0x002dfe08)  Line 739 + 0x9 bytes	C
!_mymalloc(unsigned int size=8, const char * filename=0x005146a0, unsigned int lineno=82, int MyFlags=16)  Line 126 + 0x21 bytes	C
!String::realloc(unsigned long alloc_length=0)  Line 82 + 0x12 bytes	C++
!String::c_ptr()  Line 91	C++
!read_and_execute(int interactive=1)  Line 1092 + 0x8 bytes	C++
!main(int argc=4, char * * argv=0x01e64b30)  Line 502 + 0x12 bytes	C++
!__tmainCRTStartup()  Line 318 + 0x19 bytes	C
!mainCRTStartup()  Line 187	C

How to repeat:
build debug version of mysql client.

mysql -uroot test
ctrl-c

Suggested fix:
don't crash.  the 'stack' variable is NULL in this code.

if (TRACING && !state->disable_output &&
      state->level <= stack -> maxdepth &&
      InList (stack -> functions, state->func) &&
      InList (stack -> processes, _db_process_))
      trace = TRUE;

So, check if it's null before using it.
[26 Jan 2008 22:41] Roland Bouman
Is this a duplicate of:

http://bugs.mysql.com/bug.php?id=26243

?
[27 Jan 2008 9:14] MySQL Verification Team
no, it's the same bug report !!!
[26 Mar 2008 22:28] 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/44484

ChangeSet@1.2594, 2008-03-26 18:28:03-04:00, iggy@amd64.(none) +19 -0
  Bug#26243 mysql command line crash after control-c
  - Backported the 5.1 DBUG to 5.0.
  - Avoid memory cleanup race on Windows client for CTRL-C
[27 Mar 2008 19:01] Vladislav Vaintroub
Looks fine to me. The patch became quite big since it contains also 
the downport of DBUG,  but I'm ok with it, and think it is even easier to maintain this way.
[28 Mar 2008 18:03] 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/44614

ChangeSet@1.2599, 2008-03-28 14:02:27-04:00, iggy@amd64.(none) +19 -0
  Bug#26243 mysql command line crash after control-c
  - Backported the 5.1 DBUG to 5.0.
  - Avoid memory cleanup race on Windows client for CTRL-C
[30 Mar 2008 19:47] 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/44659

ChangeSet@1.2608, 2008-03-30 15:46:37-04:00, iggy@amd64.(none) +1 -0
  Bug#26243 - Cleanup Valgrind error
[31 Mar 2008 14:52] Bugs System
Pushed into 5.0.60
[31 Mar 2008 14:54] Bugs System
Pushed into 5.1.24-rc
[31 Mar 2008 18:43] Paul DuBois
Noted in 5.0.60, 5.1.24 changelogs.

On Windows, for distributions built with debugging support, mysql
could crash if the user typed Control-C.

Resetting report to Patch pending waiting for push into 6.0.x
[31 Mar 2008 19:04] Paul DuBois
Changing status to Patch *queued*.
[3 Apr 2008 13:02] Bugs System
Pushed into 6.0.5-alpha
[7 Apr 2008 17:24] Paul DuBois
Noted in 6.0.5 changelog.