Bug #33334 mysqltest_embedded crashes when disconnecting before reap
Submitted: 18 Dec 2007 15:11 Modified: 11 Apr 2008 14:00
Reporter: Ingo Strüwing Email Updates:
Status: Closed Impact on me:
None 
Category:Tests: Server Severity:S7 (Test Cases)
Version:5.1.23 OS:Any
Assigned to: Alexey Botchkov CPU Architecture:Any
Tags: crash, embedded

[18 Dec 2007 15:11] Ingo Strüwing
Description:
main.alias                     [ fail ]

ERROR: mysqltest returned unexpected code 139, it has probably crashed

Stopping All Servers

#0  THD::clear_data_list (this=0x0) at lib_sql.cc:689
#1  emb_advanced_command (mysql=0x1131960, command=COM_QUERY, header=0x0, header_length=0, arg=0x11d43cd "DROP TABLE IF EXIST t1", arg_length=22, skip_check=1 '\001', stmt=0x0) at lib_sql.cc:80
#2  mysql_send_query (mysql=0x1131960, query=0x11d43cd "DROP TABLE IF EXIST t1", length=22) at client.c:2786
#3  send_one_query (arg=0x1131960) at mysqltest.c:500
#4  start_thread () from /lib/libpthread.so.0
#5  clone () from /lib/libc.so.6

The problem is that cn->mysql->thd is NULL. I guess that 'disconnect' clears the resources for the thread without terminating it.

How to repeat:
Append the following four lines to the end of an arbitrary test case, e.g. alias.test:

connect (con1,localhost,root,,);
send DROP TABLE IF EXIST t1;
disconnect con1;
connection default;

[EOF here, no more statements.]

cd mysql-test && ./mysql-test-run.pl --embedded-server alias

Suggested fix:
Either handle it smoothly and/or report an error about the forgotten 'reap'.

Keep track of the created and ended threads. Before clearing resources of an existing thread, cancel it and wait for it to end. Perhaps pthread_cancel() and pthread_join() could do that.
[11 Feb 2008 17:04] 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/42055

ChangeSet@1.2594, 2008-02-11 15:59:01+04:00, holyfoot@mysql.com +1 -0
  Bug #33334 mysqltest_embedded crashes when disconnecting before reap.
  
  Before breaking the connection we have to check that there's no query
  executing at the moment. Otherwise it can lead to crash in embedded server.
[11 Feb 2008 17:57] 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/42061

ChangeSet@1.2594, 2008-02-11 16:13:03+04:00, holyfoot@mysql.com +1 -0
  Bug #33334 mysqltest_embedded crashes when disconnecting before reap.
  
  Wait until the query thread is finished before we break the connection.
[19 Feb 2008 12:13] Alexey Botchkov
Don't mind the second patch - was sent by mistake.
[26 Feb 2008 20:08] 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/43016

ChangeSet@1.2608, 2008-02-27 00:00:14+04:00, holyfoot@mysql.com +3 -0
  Bug #33334 mysqltest_embedded crashes when disconnecting before reap.
  
  Before breaking the connection we have to check that there's no query
    executing at the moment. Otherwise it can lead to crash in embedded server.
[19 Mar 2008 12:01] 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/44217

ChangeSet@1.2608, 2008-03-19 15:51:22+04:00, holyfoot@mysql.com +3 -0
  Bug #33334 mysqltest_embedded crashes when disconnecting before reap.
  
  Before breaking the connection we have to check that there's no query
    executing at the moment. Otherwise it can lead to crash in embedded server.
[28 Mar 2008 9:21] Bugs System
Pushed into 5.1.24-rc
[28 Mar 2008 9:22] Bugs System
Pushed into 5.0.60
[31 Mar 2008 13:58] Bugs System
Pushed into 6.0.5-alpha
[11 Apr 2008 14:00] Jon Stephens
Change in tests only, no user changes to document. Closed w/o further action.