Bug #51234 crash with --skip-grant-tables and insert delayed,trigger,function in other db
Submitted: 17 Feb 2010 10:18 Modified: 11 Jun 2012 16:51
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S1 (Critical)
Version:5.1.43, 5.5.1-m2 OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any
Tags: insert delayed, regression, skip-grant-tables

[17 Feb 2010 10:18] Shane Bester
Description:
5.1.43 stack trace:
mysqld.exe!calc_hash()[hash.c:44]
mysqld.exe!my_hash_insert()[hash.c:432]
mysqld.exe!acl_get()[sql_acl.cc:1412]
mysqld.exe!mysql_change_db()[sql_db.cc:1615]
mysqld.exe!mysql_opt_change_db()[sql_db.cc:1712]
mysqld.exe!db_load_routine()[sp.cc:776]
mysqld.exe!db_find_routine()[sp.cc:672]
mysqld.exe!sp_cache_routines_and_add_tables_aux()[sp.cc:1871]
mysqld.exe!open_tables()[sql_base.cc:4685]
mysqld.exe!open_and_lock_tables_derived()[sql_base.cc:4992]
mysqld.exe!open_n_lock_single_table()[sql_base.cc:4874]
mysqld.exe!handle_delayed_insert_impl()[sql_insert.cc:2331]
mysqld.exe!handle_delayed_insert()[sql_insert.cc:2544]
mysqld.exe!pthread_start()[my_winthread.c:85]
mysqld.exe!_callthreadstart()[thread.c:295]
mysqld.exe!_threadstart()[thread.c:275]
kernel32.dll!BaseThreadStart()

5.0.x didn't crash.

How to repeat:
start server with --skip-grant-tables and run this sql.

---
drop database if exists db1;
drop database if exists db2;
create database db1;
create database db2;
use db2;
create table t2(a int)engine=myisam;
drop function if exists f1;
create function f1() returns int return 0;
use db1;
drop table if exists t1;
create table t1(a int)engine=myisam;

delimiter $
create trigger `t1_after_insert` after insert on `t1` 
for each row begin
   insert into db2.t2 (select db2.f1());
end $

delimiter ;
insert delayed into t1 values (1);
---
[17 Feb 2010 10:51] Valeriy Kravchuk
Recent 5.1.45-debug from bzr just hands for me on last statement.
[17 Feb 2010 11:30] MySQL Verification Team
Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\DBS>5.1\bin\mysqld --standalone --console --skip-grant-tables
100217  9:28:20 [Note] Plugin 'FEDERATED' is disabled.
100217  9:28:20  InnoDB: Started; log sequence number 0 47511
100217  9:28:20 [Note] 5.1\bin\mysqld: ready for connections.
Version: '5.1.45-Win X64-debug'  socket: ''  port: 3306  Source distribution
100217  9:29:17 - mysqld got exception 0xc0000005 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8384512
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=2
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338112 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x4116ab8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
0000000140620A0C    mysqld.exe!calc_hash()[hash.c:44]
0000000140621468    mysqld.exe!rec_hashnr()[hash.c:208]
00000001406211D9    mysqld.exe!my_hash_insert()[hash.c:432]
0000000140163F6C    mysqld.exe!hash_filo::add()[hash_filo.h:118]
00000001401934B5    mysqld.exe!acl_get()[sql_acl.cc:1419]
00000001401AFECE    mysqld.exe!mysql_change_db()[sql_db.cc:1631]
00000001401B02D1    mysqld.exe!mysql_opt_change_db()[sql_db.cc:1728]
0000000140306C1A    mysqld.exe!db_load_routine()[sp.cc:776]
0000000140306816    mysqld.exe!db_find_routine()[sp.cc:672]
0000000140307B84    mysqld.exe!sp_cache_routines_and_add_tables_aux()[sp.cc:1887]
0000000140308131    mysqld.exe!sp_cache_routines_and_add_tables_for_triggers()[sp.cc:2057]
000000014016FDD2    mysqld.exe!open_tables()[sql_base.cc:4693]
0000000140171162    mysqld.exe!open_and_lock_tables_derived()[sql_base.cc:5000]
00000001400984CA    mysqld.exe!simple_open_n_lock_tables()[mysql_priv.h:1572]
00000001401709DF    mysqld.exe!open_n_lock_single_table()[sql_base.cc:4878]
000000014037F024    mysqld.exe!handle_delayed_insert_impl()[sql_insert.cc:2331]
000000014037EDD3    mysqld.exe!handle_delayed_insert()[sql_insert.cc:2544]
0000000140604375    mysqld.exe!pthread_start()[my_winthread.c:85]
00000001405DA5E5    mysqld.exe!_callthreadstart()[thread.c:295]
00000001405DA5B7    mysqld.exe!_threadstart()[thread.c:277]
000000007750BE3D    kernel32.dll!BaseThreadInitThunk()
0000000077646A51    ntdll.dll!RtlUserThreadStart()
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0000000002015E08=t1
thd->thread_id=2
thd->killed=NOT_KILLED
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

C:\DBS>
[17 Feb 2010 11:33] MySQL Verification Team
Thank you for the bug report. Verified as described.
[11 Jun 2012 16:51] Jon Olav Hauglid
Already fixed in 5.5/5.6