Description:
Crashing / segfault in clear_tables (join=0xa4d3cc0) at sql_select.cc:7302
Bug is 5.1-bugteam only, tested against 6.0-codebase and 5.0-bugteam and it was not present.
Query:
NOTE: automated query simplification did not work here as the simplified query exhibited another (documented bug). Using full, original query here to reproduce the crash:
SELECT DISTINCT SUM( table2 . `col_int_key` ) AS field1 , SUM( table1 . `col_int_key` ) AS field2
FROM ( (
SELECT SUBQUERY1_t1 . *
FROM D AS SUBQUERY1_t1
WHERE SUBQUERY1_t1 . `pk` != SOME (
SELECT 5 UNION
SELECT 1 ) ) AS table1 STRAIGHT_JOIN (
SELECT SUBQUERY2_t1 . *
FROM B AS SUBQUERY2_t1 ) AS table2 ON (table2 . `col_varchar_nokey` = table1 . `col_varchar_key` ) )
WHERE ( NOT EXISTS (
SELECT DISTINCT SUBQUERY3_t1 . `col_varchar_nokey` AS SUBQUERY3_field1
FROM ( B AS SUBQUERY3_t1 LEFT OUTER JOIN A AS SUBQUERY3_t2 ON (SUBQUERY3_t2 . `col_varchar_key` = SUBQUERY3_t1 . `col_varchar_key` ) )
WHERE SUBQUERY3_t1 . `col_varchar_key` = table2 . `col_varchar_key` ) ) AND ( table1 . `pk` = 93 AND table1 . `col_varchar_key` = 'h' ) OR ( table1 . `col_int_nokey` IS NOT NULL AND table1 . `pk` = table1 . `col_int_key` )
HAVING ( 'k', 't' ) IN (
SELECT SUBQUERY4_t2 . `col_varchar_nokey` AS SUBQUERY4_field1 , SUM( SUBQUERY4_t1 . `col_varchar_key` ) AS SUBQUERY4_field2
FROM ( CC AS SUBQUERY4_t1 INNER JOIN C AS SUBQUERY4_t2 ON (SUBQUERY4_t2 . `col_int_key` = SUBQUERY4_t1 . `pk` ) ) )
ORDER BY table1 . `col_time_key` DESC , field1, field2
LIMIT 1000 OFFSET 9
;
Crash output (full output attached as separate file due to space limitations):
# 2010-03-24T17:27:38 Thread 1 (Thread 24567):
# 2010-03-24T17:27:38 #0 0x00164422 in __kernel_vsyscall ()
# 2010-03-24T17:27:38 #1 0x00eeee93 in __pthread_kill (threadid=2995694448, signo=11) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:64
# 2010-03-24T17:27:38 #2 0x08cbd8a6 in my_write_core (sig=11) at stacktrace.c:329
# 2010-03-24T17:27:38 #3 0x083cfad2 in handle_segfault (sig=11) at mysqld.cc:2570
# 2010-03-24T17:27:38 #4 <signal handler called>
# 2010-03-24T17:27:38 #5 0x084f3679 in clear_tables (join=0xa4d3cc0) at sql_select.cc:7302
# 2010-03-24T17:27:38 #6 0x0852005f in JOIN::clear (this=0xa4d3cc0) at sql_select.cc:16214
# 2010-03-24T17:27:38 #7 0x0850b88c in end_send_group (join=0xa4d3cc0, join_tab=0xa4d8060, end_of_records=true) at sql_select.cc:12324
# 2010-03-24T17:27:38 #8 0x085063c3 in sub_select (join=0xa4d3cc0, join_tab=0xa4d7ecc, end_of_records=true) at sql_select.cc:11276
# 2010-03-24T17:27:38 #9 0x085063c3 in sub_select (join=0xa4d3cc0, join_tab=0xa4d7d38, end_of_records=true) at sql_select.cc:11276
# 2010-03-24T17:27:38 #10 0x08505a99 in do_select (join=0xa4d3cc0, fields=0xa4d4e28, table=0x0, procedure=0x0) at sql_select.cc:11069
# 2010-03-24T17:27:38 #11 0x084db4a6 in JOIN::exec (this=0xa4d3cc0) at sql_select.cc:2315
# 2010-03-24T17:27:38 #12 0x0833453a in subselect_single_select_engine::exec (this=0xa4a9718) at item_subselect.cc:1972
# 2010-03-24T17:27:38 #13 0x08328ad1 in Item_subselect::exec (this=0xa4a9668) at item_subselect.cc:265
# 2010-03-24T17:27:38 #14 0x0832cb80 in Item_in_subselect::val_bool (this=0xa4a9668) at item_subselect.cc:865
# 2010-03-24T17:27:38 #15 0x0823e536 in Item::val_bool_result (this=0xa4a9668) at item.h:745
# 2010-03-24T17:27:38 #16 0x082a4086 in Item_in_optimizer::val_int (this=0xa4d1c30) at item_cmpfunc.cc:1833
# 2010-03-24T17:27:38 #17 0x084f32fd in return_zero_rows (join=0xa4d0888, result=0xa4d0870, tables=0xa51a518, fields=..., send_row=true, select_options=2147764737,
# 2010-03-24T17:27:38 info=0x8ea80c8 "Impossible HAVING noticed after reading const tables", having=0xa4d1c30) at sql_select.cc:7269
# 2010-03-24T17:27:38 #18 0x084d7bf2 in JOIN::exec (this=0xa4d0888) at sql_select.cc:1834
# 2010-03-24T17:27:38 #19 0x084dc3dd in mysql_select (thd=0xa42d700, rref_pointer_array=0xa42eba0, tables=0xa51a518, wild_num=0, fields=..., conds=0xa534f40, og_num=3,
# 2010-03-24T17:27:38 order=0xa4a9810, group=0x0, having=0xa4a9668, proc_param=0x0, select_options=2147764737, result=0xa4d0870, unit=0xa42e838, select_lex=0xa42eaa8)
# 2010-03-24T17:27:38 at sql_select.cc:2510
# 2010-03-24T17:27:38 #20 0x084cd9c5 in handle_select (thd=0xa42d700, lex=0xa42e7dc, result=0xa4d0870, setup_tables_done_option=0) at sql_select.cc:269
# 2010-03-24T17:27:38 #21 0x08408425 in execute_sqlcom_select (thd=0xa42d700, all_tables=0xa51a518) at sql_parse.cc:5052
# 2010-03-24T17:27:38 #22 0x083f5598 in mysql_execute_command (thd=0xa42d700) at sql_parse.cc:2248
# 2010-03-24T17:27:38 #23 0x0840cb28 in mysql_parse (thd=0xa42d700,
# 2010-03-24T17:27:38 inBuf=0xa4860a0 "SELECT DISTINCT SUM( table2 . `col_int_key` ) AS field1 , SUM( table1 . `col_int_key` ) AS field2 FROM ( ( SELECT SUBQUERY1_t1 . * FROM D AS SUBQUERY1_t1 WHERE SUBQUERY1_t1 . `pk` != SOME ( SE"..., length=1185, found_semicolon=0xb28ea058) at sql_parse.cc:5971
# 2010-03-24T17:27:38 #24 0x083f09d8 in dispatch_command (command=COM_QUERY, thd=0xa42d700,
# 2010-03-24T17:27:38 packet=0xa497c79 " SELECT DISTINCT SUM( table2 . `col_int_key` ) AS field1 , SUM( table1 . `col_int_key` ) AS field2 FROM ( ( SELECT SUBQUERY1_t1 . * FROM D AS SUBQUERY1_t1 WHERE SUBQUERY1_t1 . `pk` != SOME ( "..., packet_length=1187) at sql_parse.cc:1233
# 2010-03-24T17:27:38 #25 0x083eec2f in do_command (thd=0xa42d700) at sql_parse.cc:874
# 2010-03-24T17:27:38 #26 0x083eb29b in handle_one_connection (arg=0xa42d700) at sql_connect.cc:1127
# 2010-03-24T17:27:38 #27 0x00ee980e in start_thread (arg=0xb28eab70) at pthread_create.c:300
# 2010-03-24T17:27:38 #28 0x005558de in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
How to repeat:
MTR test case is attached as a separate file due to space limitations