Bug #2526 --init-file crashes MySQL if contains large select
Submitted: 26 Jan 2004 20:09 Modified: 5 Feb 2004 2:28
Reporter: Peter Zaitsev (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.17 OS:
Assigned to: Bugs System CPU Architecture:Any

[26 Jan 2004 20:09] Peter Zaitsev
Description:
If --init-file=file.sql is supplied and file.sql contains select query which 
returns large amount of data MySQL crashes on startup. 

How to repeat:
Start MySQL with --init-file=file.sql and have file.sql containing:

select * from test.ten, test.ten t1, test.ten t2, test.ten t3, test.ten t4, test.ten t5, test.ten t6, test.ten t7;

Table:

use test;
CREATE TABLE ten (
  i int(11) default NULL
) TYPE=MyISAM;

INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
[29 Jan 2004 4:50] Alexander Keremidarski
Crash happens at
net_serv.cc:390

net_real_write(NET *net,const char *packet,ulong len)
...

  my_bool net_blocking = vio_is_blocking(net->vio);

(gdb) bt
#0  0x0810f3e0 in net_real_write (net=0x8a34a1c, packet=0x8a3d480 "\001", len=16384) at net_serv.cc:390
#1  0x0810f32b in net_write_buff (net=0x8a34a1c, packet=0x8a6bd20 "\0014\0011\0019\0011\0011\0011\0011\0011\0011¥¥¥¥¥¥¥", len=16) at net_serv.cc:343
#2  0x0810f0e0 in my_net_write (net=0x8a34a1c, packet=0x8a6bd20 "\0014\0011\0019\0011\0011\0011\0011\0011\0011¥¥¥¥¥¥¥", len=16) at net_serv.cc:252
#3  0x0810af84 in select_send::send_data(List<Item>&) (this=0x8a41a88, items=@0x0) at sql_string.h:64
#4  0x08153ab3 in end_send (join=0x60380258, join_tab=0x8a42f68, end_of_records=false) at sql_select.cc:5305
#5  0x08152bf3 in flush_cached_records (join=0x60380258, join_tab=0x8a42e4c, skipp_last=false) at sql_select.cc:4810
#6  0x08152829 in sub_select_cache (join=0x60380258, join_tab=0x8a42e4c, end_of_records=false) at sql_select.cc:4685
#7  0x08152bf3 in flush_cached_records (join=0x60380258, join_tab=0x8a42d30, skipp_last=false) at sql_select.cc:4810
#8  0x08152829 in sub_select_cache (join=0x60380258, join_tab=0x8a42d30, end_of_records=false) at sql_select.cc:4685
#9  0x08152bf3 in flush_cached_records (join=0x60380258, join_tab=0x8a42c14, skipp_last=false) at sql_select.cc:4810
#10 0x08152829 in sub_select_cache (join=0x60380258, join_tab=0x8a42c14, end_of_records=false) at sql_select.cc:4685
#11 0x08152bf3 in flush_cached_records (join=0x60380258, join_tab=0x8a42af8, skipp_last=false) at sql_select.cc:4810
#12 0x08152829 in sub_select_cache (join=0x60380258, join_tab=0x8a42af8, end_of_records=false) at sql_select.cc:4685
#13 0x08152bf3 in flush_cached_records (join=0x60380258, join_tab=0x8a429dc, skipp_last=false) at sql_select.cc:4810
#14 0x0815283f in sub_select_cache (join=0x60380258, join_tab=0x8a429dc, end_of_records=true) at sql_select.cc:4687
#15 0x081528a1 in sub_select (join=0x60380258, join_tab=0x8a428c0, end_of_records=28) at sql_select.cc:4699
#16 0x08152858 in sub_select_cache (join=0x60380258, join_tab=0x8a428c0, end_of_records=true) at sql_select.cc:4689
#17 0x081528a1 in sub_select (join=0x60380258, join_tab=0x8a427a4, end_of_records=28) at sql_select.cc:4699
#18 0x08152858 in sub_select_cache (join=0x60380258, join_tab=0x8a427a4, end_of_records=true) at sql_select.cc:4689
#19 0x081528a1 in sub_select (join=0x60380258, join_tab=0x8a42688, end_of_records=28) at sql_select.cc:4699
#20 0x08152665 in do_select (join=0x60380258, fields=0x8a42688, table=0x0, procedure=0x0) at sql_select.cc:4619
#21 0x08149b29 in mysql_select(THD*, st_table_list*, List<Item>&, Item*, st_order*, st_order*, Item*, st_order*, unsigned long, select_result*) (thd=0x8a34a10, tables=0x8a416b8, fields=@0x8a34bbc, conds=0x0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=17339392, result=0x8a41a88) at sql_select.cc:1012
#22 0x08147368 in handle_select(THD*, st_lex*, select_result*) (thd=0x8a34a10, lex=0x0, result=0x8a41a88) at sql_select.cc:183
#23 0x08126745 in mysql_execute_command() () at sql_parse.cc:1449
#24 0x0812b00c in mysql_parse(THD*, char*, unsigned) (thd=0x8a34a10, inBuf=0x8a34b40 "\001", length=113) at sql_parse.cc:3003
#25 0x08124b51 in handle_bootstrap (arg=0x0) at sql_parse.cc:820
#26 0x45255484 in start_thread () from /lib/tls/libpthread.so.0
#27 0x450a9147 in clone () from /lib/tls/libc.so.6
[5 Feb 2004 2:28] Victor Vagin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html