Bug #28280 insert delayed on a table containing trigger leads to server crash
Submitted: 7 May 2007 13:47 Modified: 29 May 2007 13:29
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S1 (Critical)
Version:5.0.42BK, 5.1.18BK OS:Any
Assigned to: CPU Architecture:Any
Tags: crash

[7 May 2007 13:47] Shane Bester
Description:
insert delayed into a table where a trigger exists may lead
to a server crash.  the testcase causes a crash with this stack trace:
(truncated to be readable on bug report)

handle_segfault + 529                              
__pthread_sighandler + 173                         
__kill + 17                                        
__pthread_raise + 27                               
abort + 340                                        
__assert_fail + 224                                
_ZN10Field_long7val_intEv + 72                     
_Z10field_convP5FieldS0_ + 1014                    
_ZN10Item_field13save_in_fieldEP5Fieldb + 118      
_Z11fill_recordP3THDR4ListI4ItemES4_b + 266        
_Z36fill_record_n_invoke_before_triggersP3THDR4List
_Z12mysql_insertP3THDP13st_table_listR4ListI4ItemER
_Z21mysql_execute_commandP3THD + 11037             
_ZN13sp_instr_stmt9exec_coreEP3THDPj + 17          
_ZN13sp_lex_keeper23reset_lex_and_exec_coreEP3THDPj
_ZN13sp_instr_stmt7executeEP3THDPj + 261           
_ZN7sp_head7executeEP3THD + 1388                   
_ZN7sp_head15execute_triggerEP3THDPKcS3_P13st_grant
_ZN19Table_triggers_list16process_triggersEP3THD14t
_Z36fill_record_n_invoke_before_triggersP3THDR4List
_Z12mysql_insertP3THDP13st_table_listR4ListI4ItemER
_Z21mysql_execute_commandP3THD + 11037             
_Z11mysql_parseP3THDPcj + 308                      
_Z16dispatch_command19enum_server_commandP3THDPcj +
_Z10do_commandP3THD + 529                          
handle_one_connection + 874                        
pthread_start_thread + 225                         
__clone + 106                                      

How to repeat:
#if release binary doesn't crash, try debug binary

delimiter ;
drop table if exists t1;
drop table if exists t2;
drop trigger t1_trig1;
create table t1(c1 int,c2 varchar(200),key(c2))engine=myisam;
create table t2(c1 varchar(10),c2 int,key(c2))engine=myisam;
delimiter //
create trigger t1_trig1 before insert on t1 for each row begin insert into t2(c1,c2) values (new.c1,new.c2);end//
delimiter ;
insert delayed into t1(c1,c2) values (0,'0');
insert delayed into t1(c1,c2) values (0,'0');
insert delayed into t1(c1,c2) values (0,'0');
insert delayed into t1(c1,c2) values (0,'0');
insert delayed into t1(c1,c2) values (0,'0');

Suggested fix:
.
[7 May 2007 13:57] MySQL Verification Team
On Windows debug build we find this in error log, before a crash:

>mysqld-debug --console --skip-grant-tables
070507 15:55:55  InnoDB: Started; log sequence number 0 48849596
070507 15:55:55 [Note] mysqld-debug: ready for connections.
Version: '5.0.42-debug'  socket: ''  port: 3306  yes
Assertion failed: table->in_use == _current_thd(), file .\field.cpp, line 3314

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
[16 May 2007 14:34] Konstantin Osipov
Thank you for a bug report.
I can't repeat it in the latest tree.
It is likely a duplicate of Bug#21483.
[29 May 2007 13:29] Valeriy Kravchuk
Likely a duplicate of bug #21483. Not repeatable with 5.0.44-BK.