Bug #20033 creating a temporary table crashes server when client quits
Submitted: 24 May 2006 5:06 Modified: 6 Jun 2006 8:40
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0-bk OS:Linux (linux/windows)
Assigned to: Assigned Account CPU Architecture:Any

[24 May 2006 5:06] Shane Bester
Description:
Only recent BK builds (since ~ 21 May 2006) servers on windows and linux have been crashing during a thread's cleanup procedure if it created a temporary table in a stored procedure.  When the client disconnects, the server crashes.

So far I only saw -debug builds crash.
See in the stack trace the invalid table object.

------
close_temporary(st_table * table=0xdddddddd, int delete_table=0x00000001) 
close_temporary_tables(THD * thd=0x0427f7c0)
THD::cleanup() 
end_thread(THD * thd=0x0427f7c0, int put_in_cache=0x00000001) 
handle_one_connection(void * arg=0x0427f7c0) 
pthread_start(void * param=0x01455230)
_threadstart(void * ptd=0x0429ceb8) 
------

How to repeat:
USE TEST;
DROP PROCEDURE IF EXISTS `kbug`;
delimiter //
CREATE PROCEDURE `kbug`()
BEGIN
    DROP TABLE IF EXISTS `bfug`;
    CREATE TEMPORARY TABLE `bfug` (a INT)ENGINE=MyISAM;
end//
delimiter ;
CALL kbug();
exit;

Suggested fix:
not sure
[24 May 2006 5:40] MySQL Verification Team
updated synopsis. new testcase;

mysql> create temporary table tt(id int);
Query OK, 0 rows affected (0.02 sec)

mysql> exit
Bye

<server crashes here>
[24 May 2006 6:07] Tonci Grgin
Verified on Suse with bk debug build of 2006-05-23.
Windows mysqld-max-nt built from the same repo didn't crash.