Server crash in in JOIN_CACHE_HASHED::put_record or Assertion `0' failed in Field_blob_compressed::new_key_field or Assertion `length > 0' failed in create_ref_for_key or SIGSEGV in store_key::copy, with join_cache_level>2
A very similar test case produces a crash on a non-debug build:
SET join_cache_level= 3;
CREATETABLE t1 (b BLOB);
INSERTINTO t1 VALUES (''),('');
CREATETABLE t2 (pk INTPRIMARYKEY, b BLOB COMPRESSED);
INSERTINTO t2 VALUES (1,''),(2,'');
SELECT * FROM t1 JOIN t2 USING (b);
# Cleanup
DROPTABLE t1, t2;
10.3 95f3c142a4 RelWIthDebInfo
#2 <signal handler called>
#3 0x000055904e8615e9 in copy (this=0x7f4e1c0163b0) at /data/src/10.3/sql/sql_select.h:1865
#4 cp_buffer_from_ref (thd=0x7f4e1c0009a8, table=<optimized out>, ref=ref@entry=0x7f4e1c015d58) at /data/src/10.3/sql/sql_select.cc:22952
#5 0x000055904e91d2cc in JOIN_CACHE_HASHED::put_record (this=0x7f4e1c016a88) at /data/src/10.3/sql/sql_join_cache.cc:2930
#6 0x000055904e8520d1 in sub_select_cache (join=0x7f4e1c012dd8, join_tab=0x7f4e1c015b18, end_of_records=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19189
#7 0x000055904e845620 in evaluate_join_record (join=join@entry=0x7f4e1c012dd8, join_tab=join_tab@entry=0x7f4e1c015768, error=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19616
#8 0x000055904e851ccb in sub_select (join=0x7f4e1c012dd8, join_tab=0x7f4e1c015768, end_of_records=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19396
#9 0x000055904e875790 in do_select (procedure=0x0, join=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:18936
#10 JOIN::exec_inner (this=this@entry=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:4040
#11 0x000055904e8759c9 in JOIN::exec (this=this@entry=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:3834
#12 0x000055904e875b0f in mysql_select (thd=thd@entry=0x7f4e1c0009a8, tables=0x7f4e1c011898, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f4e1c012db0, unit=0x7f4e1c004698, select_lex=0x7f4e1c004e08) at /data/src/10.3/sql/sql_select.cc:4239
#13 0x000055904e876527 in handle_select (thd=thd@entry=0x7f4e1c0009a8, lex=lex@entry=0x7f4e1c0045d0, result=result@entry=0x7f4e1c012db0, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/src/10.3/sql/sql_select.cc:385
#14 0x000055904e73f4b4 in execute_sqlcom_select (thd=0x7f4e1c0009a8, all_tables=0x7f4e1c011898) at /data/src/10.3/sql/sql_parse.cc:6547
#15 0x000055904e8203c3 in mysql_execute_command (thd=0x7f4e1c0009a8) at /data/src/10.3/sql/sql_parse.cc:3768
#16 0x000055904e822a39 in mysql_parse (thd=0x7f4e1c0009a8, rawbuf=<optimized out>, length=34, parser_state=0x7f4e2c240630, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/src/10.3/sql/sql_parse.cc:8091
#17 0x000055904e825d8e in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f4e1c0009a8, packet=packet@entry=0x7f4e1c009319 "", packet_length=packet_length@entry=34, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.3/sql/sql_parse.cc:1850
#18 0x000055904e826430 in do_command (thd=0x7f4e1c0009a8) at /data/src/10.3/sql/sql_parse.cc:1395
#19 0x000055904e8f7c54 in do_handle_one_connection (connect=connect@entry=0x559050d45b18) at /data/src/10.3/sql/sql_connect.cc:1402
#20 0x000055904e8f7df4 in handle_one_connection (arg=arg@entry=0x559050d45b18) at /data/src/10.3/sql/sql_connect.cc:1308
#21 0x000055904ebdb4e4 in pfs_spawn_thread (arg=0x559050db6958) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#22 0x00007f4e33b57494 in start_thread (arg=0x7f4e2c241700) at pthread_create.c:333
#23 0x00007f4e3215893f in clone () from /lib/x86_64-linux-gnu/libc.so.6
Reproducible with at least MyISAM and InnoDB.
On a debug build, it causes the same assertion failure as in the description.
Elena Stepanova
added a comment - - edited A very similar test case produces a crash on a non-debug build:
SET join_cache_level= 3;
CREATE TABLE t1 (b BLOB);
INSERT INTO t1 VALUES ( '' ),( '' );
CREATE TABLE t2 (pk INT PRIMARY KEY , b BLOB COMPRESSED);
INSERT INTO t2 VALUES (1, '' ),(2, '' );
SELECT * FROM t1 JOIN t2 USING (b);
# Cleanup
DROP TABLE t1, t2;
10.3 95f3c142a4 RelWIthDebInfo
#2 <signal handler called>
#3 0x000055904e8615e9 in copy (this=0x7f4e1c0163b0) at /data/src/10.3/sql/sql_select.h:1865
#4 cp_buffer_from_ref (thd=0x7f4e1c0009a8, table=<optimized out>, ref=ref@entry=0x7f4e1c015d58) at /data/src/10.3/sql/sql_select.cc:22952
#5 0x000055904e91d2cc in JOIN_CACHE_HASHED::put_record (this=0x7f4e1c016a88) at /data/src/10.3/sql/sql_join_cache.cc:2930
#6 0x000055904e8520d1 in sub_select_cache (join=0x7f4e1c012dd8, join_tab=0x7f4e1c015b18, end_of_records=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19189
#7 0x000055904e845620 in evaluate_join_record (join=join@entry=0x7f4e1c012dd8, join_tab=join_tab@entry=0x7f4e1c015768, error=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19616
#8 0x000055904e851ccb in sub_select (join=0x7f4e1c012dd8, join_tab=0x7f4e1c015768, end_of_records=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19396
#9 0x000055904e875790 in do_select (procedure=0x0, join=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:18936
#10 JOIN::exec_inner (this=this@entry=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:4040
#11 0x000055904e8759c9 in JOIN::exec (this=this@entry=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:3834
#12 0x000055904e875b0f in mysql_select (thd=thd@entry=0x7f4e1c0009a8, tables=0x7f4e1c011898, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f4e1c012db0, unit=0x7f4e1c004698, select_lex=0x7f4e1c004e08) at /data/src/10.3/sql/sql_select.cc:4239
#13 0x000055904e876527 in handle_select (thd=thd@entry=0x7f4e1c0009a8, lex=lex@entry=0x7f4e1c0045d0, result=result@entry=0x7f4e1c012db0, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/src/10.3/sql/sql_select.cc:385
#14 0x000055904e73f4b4 in execute_sqlcom_select (thd=0x7f4e1c0009a8, all_tables=0x7f4e1c011898) at /data/src/10.3/sql/sql_parse.cc:6547
#15 0x000055904e8203c3 in mysql_execute_command (thd=0x7f4e1c0009a8) at /data/src/10.3/sql/sql_parse.cc:3768
#16 0x000055904e822a39 in mysql_parse (thd=0x7f4e1c0009a8, rawbuf=<optimized out>, length=34, parser_state=0x7f4e2c240630, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/src/10.3/sql/sql_parse.cc:8091
#17 0x000055904e825d8e in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f4e1c0009a8, packet=packet@entry=0x7f4e1c009319 "", packet_length=packet_length@entry=34, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.3/sql/sql_parse.cc:1850
#18 0x000055904e826430 in do_command (thd=0x7f4e1c0009a8) at /data/src/10.3/sql/sql_parse.cc:1395
#19 0x000055904e8f7c54 in do_handle_one_connection (connect=connect@entry=0x559050d45b18) at /data/src/10.3/sql/sql_connect.cc:1402
#20 0x000055904e8f7df4 in handle_one_connection (arg=arg@entry=0x559050d45b18) at /data/src/10.3/sql/sql_connect.cc:1308
#21 0x000055904ebdb4e4 in pfs_spawn_thread (arg=0x559050db6958) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#22 0x00007f4e33b57494 in start_thread (arg=0x7f4e2c241700) at pthread_create.c:333
#23 0x00007f4e3215893f in clone () from /lib/x86_64-linux-gnu/libc.so.6
Reproducible with at least MyISAM and InnoDB.
On a debug build, it causes the same assertion failure as in the description.
[Current thread is 1 (Thread 0x14b6e4501700 (LWP 2459447))]
(gdb) bt
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1 0x000055dfe98d1021 in my_write_core (sig=sig@entry=6) at /test/10.6_dbg/mysys/stacktrace.c:424
#2 0x000055dfe9018321 in handle_fatal_signal (sig=6) at /test/10.6_dbg/sql/signal_handler.cc:330
#3 <signal handler called>
#4 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5 0x000014b6e5969859 in __GI_abort () at abort.c:79
#6 0x000014b6e5969729 in __assert_fail_base (fmt=0x14b6e5aff588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55dfe9cb6ecd "length > 0", file=0x55dfe9a434d8 "/test/10.6_dbg/sql/sql_select.cc", line=10734, function=<optimized out>) at assert.c:92
#7 0x000014b6e597af36 in __GI___assert_fail (assertion=assertion@entry=0x55dfe9cb6ecd "length > 0", file=file@entry=0x55dfe9a434d8 "/test/10.6_dbg/sql/sql_select.cc", line=line@entry=10734, function=function@entry=0x55dfe9a43fa8 "bool create_ref_for_key(JOIN*, JOIN_TAB*, KEYUSE*, bool, table_map)") at assert.c:101
#8 0x000055dfe8d940f1 in create_ref_for_key (join=join@entry=0x14b6840152e8, j=j@entry=0x14b684017af8, org_keyuse=0x14b6840170c0, allow_full_scan=allow_full_scan@entry=true, used_tables=used_tables@entry=4611686018427387907) at /test/10.6_dbg/sql/sql_select.cc:10734
#9 0x000055dfe8d96d35 in JOIN::get_best_combination (this=this@entry=0x14b6840152e8) at /test/10.6_dbg/sql/sql_select.cc:10488
#10 0x000055dfe8dd0b47 in JOIN::optimize_stage2 (this=this@entry=0x14b6840152e8) at /test/10.6_dbg/sql/sql_select.cc:2294
#11 0x000055dfe8dd4d2b in JOIN::optimize_inner (this=this@entry=0x14b6840152e8) at /test/10.6_dbg/sql/sql_select.cc:2273
#12 0x000055dfe8dd4f5d in JOIN::optimize (this=this@entry=0x14b6840152e8) at /test/10.6_dbg/sql/sql_select.cc:1623
#13 0x000055dfe8dd58f5 in mysql_select (thd=thd@entry=0x14b684000db8, tables=0x14b684012e88, fields=@0x14b684012870: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14b684012ce0, last = 0x14b684012e40, elements = 2}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14b6840152c0, unit=0x14b684004f40, select_lex=0x14b684012720) at /test/10.6_dbg/sql/sql_select.cc:4659
#14 0x000055dfe8dd5c72 in handle_select (thd=thd@entry=0x14b684000db8, lex=lex@entry=0x14b684004e78, result=result@entry=0x14b6840152c0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_dbg/sql/sql_select.cc:417
#15 0x000055dfe8d4938e in execute_sqlcom_select (thd=thd@entry=0x14b684000db8, all_tables=0x14b684012e88) at /test/10.6_dbg/sql/sql_parse.cc:6062
#16 0x000055dfe8d55aea in mysql_execute_command (thd=thd@entry=0x14b684000db8) at /test/10.6_dbg/sql/sql_parse.cc:3784
#17 0x000055dfe8d41fd2 in mysql_parse (thd=thd@entry=0x14b684000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14b6e45003d0) at /test/10.6_dbg/sql/sql_parse.cc:7833
#18 0x000055dfe8d500c7 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14b684000db8, packet=packet@entry=0x14b684008ce9 "SELECT t.c,u.c FROM t JOIN u ON t.c=u.c", packet_length=packet_length@entry=39) at /test/10.6_dbg/sql/sql_class.h:1253
#19 0x000055dfe8d533d2 in do_command (thd=0x14b684000db8) at /test/10.6_dbg/sql/sql_parse.cc:1343
#20 0x000055dfe8ead994 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55dfed7b4f18, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#21 0x000055dfe8eae09b in handle_one_connection (arg=arg@entry=0x55dfed7b4f18) at /test/10.6_dbg/sql/sql_connect.cc:1312
#22 0x000055dfe9361abb in pfs_spawn_thread (arg=0x55dfed701508) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#23 0x000014b6e5e77609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#24 0x000014b6e5a66293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
[Current thread is 1 (Thread 0x14a30004c700 (LWP 2882788))]
(gdb) bt
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1 0x00005599bea17a4f in my_write_core (sig=sig@entry=11) at /test/10.6_opt/mysys/stacktrace.c:424
#2 0x00005599be43b130 in handle_fatal_signal (sig=11) at /test/10.6_opt/sql/signal_handler.cc:330
#3 <signal handler called>
#4 0x00005599be27f5d1 in store_key::copy (this=0x14a2a8016158) at /test/10.6_opt/sql/sql_select.h:1904
#5 cp_buffer_from_ref (thd=0x14a2a8000c58, table=<optimized out>, ref=ref@entry=0x14a2a8015ad8) at /test/10.6_opt/sql/sql_select.cc:24250
#6 0x00005599be3622e1 in JOIN_CACHE_HASHED::put_record (this=0x14a2a8052c30) at /test/10.6_opt/sql/sql_join_cache.cc:2939
#7 0x00005599be26b0ee in sub_select_cache (join=0x14a2a8012930, join_tab=0x14a2a80158b0, end_of_records=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:20392
#8 0x00005599be258d29 in evaluate_join_record (join=join@entry=0x14a2a8012930, join_tab=join_tab@entry=0x14a2a8015500, error=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:20828
#9 0x00005599be26ac63 in sub_select (end_of_records=false, join_tab=0x14a2a8015500, join=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:20605
#10 sub_select (join=0x14a2a8012930, join_tab=0x14a2a8015500, end_of_records=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:20534
#11 0x00005599be299032 in do_select (procedure=<optimized out>, join=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:20152
#12 JOIN::exec_inner (this=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:4465
#13 0x00005599be2992b9 in JOIN::exec (this=this@entry=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:4246
#14 0x00005599be297367 in mysql_select (thd=0x14a2a8000c58, tables=0x14a2a8010a48, fields=<optimized out>, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14a2a8012908, unit=0x14a2a8004c20, select_lex=0x14a2a8010450) at /test/10.6_opt/sql/sql_select.cc:4673
#15 0x00005599be297d67 in handle_select (thd=thd@entry=0x14a2a8000c58, lex=lex@entry=0x14a2a8004b58, result=result@entry=0x14a2a8012908, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_opt/sql/sql_select.cc:417
#16 0x00005599be227951 in execute_sqlcom_select (thd=0x14a2a8000c58, all_tables=0x14a2a8010a48) at /test/10.6_opt/sql/sql_parse.cc:6062
#17 0x00005599be235380 in mysql_execute_command (thd=0x14a2a8000c58) at /test/10.6_opt/sql/sql_parse.cc:3784
#18 0x00005599be22203f in mysql_parse (thd=0x14a2a8000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.6_opt/sql/sql_parse.cc:7833
#19 0x00005599be22d967 in dispatch_command (command=COM_QUERY, thd=0x14a2a8000c58, packet=0x14a2a8008009 "", packet_length=<optimized out>) at /test/10.6_opt/sql/sql_class.h:1253
#20 0x00005599be22fd42 in do_command (thd=0x14a2a8000c58) at /test/10.6_opt/sql/sql_parse.cc:1343
#21 0x00005599be3336e1 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5599c1f8f8e8, put_in_cache=put_in_cache@entry=true) at /test/10.6_opt/sql/sql_connect.cc:1410
#22 0x00005599be333b5d in handle_one_connection (arg=arg@entry=0x5599c1f8f8e8) at /test/10.6_opt/sql/sql_connect.cc:1312
#23 0x00005599be6b9266 in pfs_spawn_thread (arg=0x5599c1f0ab18) at /test/10.6_opt/storage/perfschema/pfs.cc:2201
#24 0x000014a3032e3609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x000014a302ed2293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Roel Van de Paar
added a comment - - edited Discussed with Varun. Confirmed optimizer issue in optimization phase.
All testcases crash 10.5 debug as well as 10.6 debug.
Unique ID's seen so far (based on testcases in this bug):
length > 0|SIGABRT|create_ref_for_key|JOIN::get_best_combination|JOIN::optimize_stage2|JOIN::optimize_inner
0|SIGABRT|Field_blob_compressed::new_key_field|store_key::store_key|store_key_field::store_key_field|get_store_key
SIGSEGV|store_key_field::copy_inner|store_key::copy|cp_buffer_from_ref|JOIN_CACHE_HASHED::put_record
SIGSEGV|store_key::copy|cp_buffer_from_ref|JOIN_CACHE_HASHED::put_record|sub_select_cache
Second testcases crashes 10.6 opt also (SIGSEGV in store_key::copy):
10.6.0 5d4599f9750140f92cfdbbe4d292ae1b8dd456f8 (Optimized)
Core was generated by `/test/MD201020-mariadb-10.6.0-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x14a30004c700 (LWP 2882788))]
(gdb) bt
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1 0x00005599bea17a4f in my_write_core (sig=sig@entry=11) at /test/10.6_opt/mysys/stacktrace.c:424
#2 0x00005599be43b130 in handle_fatal_signal (sig=11) at /test/10.6_opt/sql/signal_handler.cc:330
#3 <signal handler called>
#4 0x00005599be27f5d1 in store_key::copy (this=0x14a2a8016158) at /test/10.6_opt/sql/sql_select.h:1904
#5 cp_buffer_from_ref (thd=0x14a2a8000c58, table=<optimized out>, ref=ref@entry=0x14a2a8015ad8) at /test/10.6_opt/sql/sql_select.cc:24250
#6 0x00005599be3622e1 in JOIN_CACHE_HASHED::put_record (this=0x14a2a8052c30) at /test/10.6_opt/sql/sql_join_cache.cc:2939
#7 0x00005599be26b0ee in sub_select_cache (join=0x14a2a8012930, join_tab=0x14a2a80158b0, end_of_records=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:20392
#8 0x00005599be258d29 in evaluate_join_record (join=join@entry=0x14a2a8012930, join_tab=join_tab@entry=0x14a2a8015500, error=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:20828
#9 0x00005599be26ac63 in sub_select (end_of_records=false, join_tab=0x14a2a8015500, join=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:20605
#10 sub_select (join=0x14a2a8012930, join_tab=0x14a2a8015500, end_of_records=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:20534
#11 0x00005599be299032 in do_select (procedure=<optimized out>, join=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:20152
#12 JOIN::exec_inner (this=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:4465
#13 0x00005599be2992b9 in JOIN::exec (this=this@entry=0x14a2a8012930) at /test/10.6_opt/sql/sql_select.cc:4246
#14 0x00005599be297367 in mysql_select (thd=0x14a2a8000c58, tables=0x14a2a8010a48, fields=<optimized out>, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14a2a8012908, unit=0x14a2a8004c20, select_lex=0x14a2a8010450) at /test/10.6_opt/sql/sql_select.cc:4673
#15 0x00005599be297d67 in handle_select (thd=thd@entry=0x14a2a8000c58, lex=lex@entry=0x14a2a8004b58, result=result@entry=0x14a2a8012908, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_opt/sql/sql_select.cc:417
#16 0x00005599be227951 in execute_sqlcom_select (thd=0x14a2a8000c58, all_tables=0x14a2a8010a48) at /test/10.6_opt/sql/sql_parse.cc:6062
#17 0x00005599be235380 in mysql_execute_command (thd=0x14a2a8000c58) at /test/10.6_opt/sql/sql_parse.cc:3784
#18 0x00005599be22203f in mysql_parse (thd=0x14a2a8000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.6_opt/sql/sql_parse.cc:7833
#19 0x00005599be22d967 in dispatch_command (command=COM_QUERY, thd=0x14a2a8000c58, packet=0x14a2a8008009 "", packet_length=<optimized out>) at /test/10.6_opt/sql/sql_class.h:1253
#20 0x00005599be22fd42 in do_command (thd=0x14a2a8000c58) at /test/10.6_opt/sql/sql_parse.cc:1343
#21 0x00005599be3336e1 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5599c1f8f8e8, put_in_cache=put_in_cache@entry=true) at /test/10.6_opt/sql/sql_connect.cc:1410
#22 0x00005599be333b5d in handle_one_connection (arg=arg@entry=0x5599c1f8f8e8) at /test/10.6_opt/sql/sql_connect.cc:1312
#23 0x00005599be6b9266 in pfs_spawn_thread (arg=0x5599c1f0ab18) at /test/10.6_opt/storage/perfschema/pfs.cc:2201
#24 0x000014a3032e3609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x000014a302ed2293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
New stack in optimized builds with this testcase.
It does not reproduce on 10.2 due to 'COMPRESSED'. With 'COMPRESSED' removed it does not crash and produces a 1/1 result.
SET JOIN_cache_level=8;
CREATETABLE t (a TEXT COMPRESSED) ENGINE=InnoDB;
INSERTINTO t VALUES (1),(2);
SELECT * FROM t A,t B WHERE A.a=B.a AND A.a IN (1);
Core was generated by `/test/MD260222-mariadb-10.9.0-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000000000 in ?? ()
[Current thread is 1 (Thread 0x1497305a8700 (LWP 4135589))]
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x0000557a9fa2e6a8 in store_key_field::copy_inner (this=0x1496f004b370) at /test/10.9_opt/sql/sql_select.h:1918
#2 0x0000557a9fa13ed4 in store_key::copy (thd=0x1496f0000c58, this=<optimized out>) at /test/10.9_opt/sql/sql_select.h:1861
#3 cp_buffer_from_ref (thd=0x1496f0000c58, table=<optimized out>, ref=ref@entry=0x1496f004acf0) at /test/10.9_opt/sql/sql_select.cc:24825
#4 0x0000557a9fb05851 in JOIN_CACHE_HASHED::put_record (this=0x1496f004c018) at /test/10.9_opt/sql/sql_join_cache.cc:3008
#5 0x0000557a9f9fffe6 in sub_select_cache (join=0x1496f0013000, join_tab=0x1496f004aac8, end_of_records=<optimized out>) at /test/10.9_opt/sql/sql_select.cc:20882
#6 0x0000557a9f9ed0b3 in evaluate_join_record (join=0x1496f0013000, join_tab=0x1496f004a718, error=<optimized out>) at /test/10.9_opt/sql/sql_select.cc:21325
#7 0x0000557a9f9ffb4b in sub_select (end_of_records=false, join_tab=0x1496f004a718, join=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:21095
#8 sub_select (join=0x1496f0013000, join_tab=0x1496f004a718, end_of_records=false) at /test/10.9_opt/sql/sql_select.cc:21024
#9 0x0000557a9fa2d9c7 in do_select (procedure=<optimized out>, join=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:20640
#10 JOIN::exec_inner (this=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:4749
#11 0x0000557a9fa2dd88 in JOIN::exec (this=this@entry=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:4527
#12 0x0000557a9fa2be91 in mysql_select (thd=0x1496f0000c58, tables=0x1496f0010f70, fields=@0x1496f0010c28: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496f0010f18, last = 0x1496f0013838, elements = 2}, <No data fields>}, conds=0x1496f00125f0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x1496f0012fd8, unit=0x1496f0004ea8, select_lex=0x1496f0010988) at /test/10.9_opt/sql/sql_select.cc:5007
#13 0x0000557a9fa2c647 in handle_select (thd=thd@entry=0x1496f0000c58, lex=lex@entry=0x1496f0004dd0, result=result@entry=0x1496f0012fd8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.9_opt/sql/sql_select.cc:543
#14 0x0000557a9f9ad0a1 in execute_sqlcom_select (thd=0x1496f0000c58, all_tables=0x1496f0010f70) at /test/10.9_opt/sql/sql_parse.cc:6252
#15 0x0000557a9f9bb3ce in mysql_execute_command (thd=0x1496f0000c58, is_called_from_prepared_stmt=<optimized out>) at /test/10.9_opt/sql/sql_parse.cc:3943
#16 0x0000557a9f9a7e26 in mysql_parse (thd=0x1496f0000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.9_opt/sql/sql_parse.cc:8027
#17 0x0000557a9f9b3fd5 in dispatch_command (command=COM_QUERY, thd=0x1496f0000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/10.9_opt/sql/sql_class.h:1362
#18 0x0000557a9f9b61c7 in do_command (thd=0x1496f0000c58, blocking=blocking@entry=true) at /test/10.9_opt/sql/sql_parse.cc:1402
#19 0x0000557a9fad5b47 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/10.9_opt/sql/sql_connect.cc:1418
#20 0x0000557a9fad5e8d in handle_one_connection (arg=arg@entry=0x557aa35e5878) at /test/10.9_opt/sql/sql_connect.cc:1312
#21 0x0000557a9fe4f631 in pfs_spawn_thread (arg=0x557aa357aa38) at /test/10.9_opt/storage/perfschema/pfs.cc:2201
#22 0x000014975153f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x000014975112d293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Roel Van de Paar
added a comment - - edited New stack in optimized builds with this testcase.
It does not reproduce on 10.2 due to 'COMPRESSED'. With 'COMPRESSED' removed it does not crash and produces a 1/1 result.
SET JOIN_cache_level=8;
CREATE TABLE t (a TEXT COMPRESSED) ENGINE=InnoDB;
INSERT INTO t VALUES (1),(2);
SELECT * FROM t A,t B WHERE A.a=B.a AND A.a IN (1);
Leads to:
10.9.0 4a2a9c02cd6611ef36bbb735c2b483dbc83580d4 (Optimized)
Core was generated by `/test/MD260222-mariadb-10.9.0-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000000000 in ?? ()
[Current thread is 1 (Thread 0x1497305a8700 (LWP 4135589))]
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x0000557a9fa2e6a8 in store_key_field::copy_inner (this=0x1496f004b370) at /test/10.9_opt/sql/sql_select.h:1918
#2 0x0000557a9fa13ed4 in store_key::copy (thd=0x1496f0000c58, this=<optimized out>) at /test/10.9_opt/sql/sql_select.h:1861
#3 cp_buffer_from_ref (thd=0x1496f0000c58, table=<optimized out>, ref=ref@entry=0x1496f004acf0) at /test/10.9_opt/sql/sql_select.cc:24825
#4 0x0000557a9fb05851 in JOIN_CACHE_HASHED::put_record (this=0x1496f004c018) at /test/10.9_opt/sql/sql_join_cache.cc:3008
#5 0x0000557a9f9fffe6 in sub_select_cache (join=0x1496f0013000, join_tab=0x1496f004aac8, end_of_records=<optimized out>) at /test/10.9_opt/sql/sql_select.cc:20882
#6 0x0000557a9f9ed0b3 in evaluate_join_record (join=0x1496f0013000, join_tab=0x1496f004a718, error=<optimized out>) at /test/10.9_opt/sql/sql_select.cc:21325
#7 0x0000557a9f9ffb4b in sub_select (end_of_records=false, join_tab=0x1496f004a718, join=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:21095
#8 sub_select (join=0x1496f0013000, join_tab=0x1496f004a718, end_of_records=false) at /test/10.9_opt/sql/sql_select.cc:21024
#9 0x0000557a9fa2d9c7 in do_select (procedure=<optimized out>, join=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:20640
#10 JOIN::exec_inner (this=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:4749
#11 0x0000557a9fa2dd88 in JOIN::exec (this=this@entry=0x1496f0013000) at /test/10.9_opt/sql/sql_select.cc:4527
#12 0x0000557a9fa2be91 in mysql_select (thd=0x1496f0000c58, tables=0x1496f0010f70, fields=@0x1496f0010c28: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496f0010f18, last = 0x1496f0013838, elements = 2}, <No data fields>}, conds=0x1496f00125f0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x1496f0012fd8, unit=0x1496f0004ea8, select_lex=0x1496f0010988) at /test/10.9_opt/sql/sql_select.cc:5007
#13 0x0000557a9fa2c647 in handle_select (thd=thd@entry=0x1496f0000c58, lex=lex@entry=0x1496f0004dd0, result=result@entry=0x1496f0012fd8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.9_opt/sql/sql_select.cc:543
#14 0x0000557a9f9ad0a1 in execute_sqlcom_select (thd=0x1496f0000c58, all_tables=0x1496f0010f70) at /test/10.9_opt/sql/sql_parse.cc:6252
#15 0x0000557a9f9bb3ce in mysql_execute_command (thd=0x1496f0000c58, is_called_from_prepared_stmt=<optimized out>) at /test/10.9_opt/sql/sql_parse.cc:3943
#16 0x0000557a9f9a7e26 in mysql_parse (thd=0x1496f0000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.9_opt/sql/sql_parse.cc:8027
#17 0x0000557a9f9b3fd5 in dispatch_command (command=COM_QUERY, thd=0x1496f0000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/10.9_opt/sql/sql_class.h:1362
#18 0x0000557a9f9b61c7 in do_command (thd=0x1496f0000c58, blocking=blocking@entry=true) at /test/10.9_opt/sql/sql_parse.cc:1402
#19 0x0000557a9fad5b47 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/10.9_opt/sql/sql_connect.cc:1418
#20 0x0000557a9fad5e8d in handle_one_connection (arg=arg@entry=0x557aa35e5878) at /test/10.9_opt/sql/sql_connect.cc:1312
#21 0x0000557a9fe4f631 in pfs_spawn_thread (arg=0x557aa357aa38) at /test/10.9_opt/storage/perfschema/pfs.cc:2201
#22 0x000014975153f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x000014975112d293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Bug confirmed present in:
MariaDB: 10.3.35 (dbg), 10.3.35 (opt), 10.4.25 (dbg), 10.4.25 (opt), 10.5.16 (dbg), 10.5.16 (opt), 10.6.8 (dbg), 10.6.8 (opt), 10.7.4 (dbg), 10.7.4 (opt), 10.8.3 (dbg), 10.8.3 (opt), 10.9.0 (dbg), 10.9.0 (opt)
Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.44 (dbg), 10.2.44 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.37 (dbg), 5.7.37 (opt), 8.0.28 (dbg), 8.0.28 (opt)
CREATETABLE t (a TEXT COMPRESSED,b TEXT) ENGINE=InnoDB;
CREATETABLE t4 LIKE t;
SET SESSION JOIN_cache_level=3;
SELECT * FROM (SELECT * FROM t) as t NATURAL JOIN (SELECT * FROM t) AS t1;
Roel Van de Paar
added a comment - Please also test any bugfix with:
CREATE TABLE t (a TEXT COMPRESSED,b TEXT) ENGINE=InnoDB;
CREATE TABLE t4 LIKE t;
SET SESSION JOIN_cache_level=3;
SELECT * FROM ( SELECT * FROM t) as t NATURAL JOIN ( SELECT * FROM t) AS t1;
A very similar test case produces a crash on a non-debug build:
# Cleanup
10.3 95f3c142a4 RelWIthDebInfo
#2 <signal handler called>
#3 0x000055904e8615e9 in copy (this=0x7f4e1c0163b0) at /data/src/10.3/sql/sql_select.h:1865
#4 cp_buffer_from_ref (thd=0x7f4e1c0009a8, table=<optimized out>, ref=ref@entry=0x7f4e1c015d58) at /data/src/10.3/sql/sql_select.cc:22952
#5 0x000055904e91d2cc in JOIN_CACHE_HASHED::put_record (this=0x7f4e1c016a88) at /data/src/10.3/sql/sql_join_cache.cc:2930
#6 0x000055904e8520d1 in sub_select_cache (join=0x7f4e1c012dd8, join_tab=0x7f4e1c015b18, end_of_records=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19189
#7 0x000055904e845620 in evaluate_join_record (join=join@entry=0x7f4e1c012dd8, join_tab=join_tab@entry=0x7f4e1c015768, error=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19616
#8 0x000055904e851ccb in sub_select (join=0x7f4e1c012dd8, join_tab=0x7f4e1c015768, end_of_records=<optimized out>) at /data/src/10.3/sql/sql_select.cc:19396
#9 0x000055904e875790 in do_select (procedure=0x0, join=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:18936
#10 JOIN::exec_inner (this=this@entry=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:4040
#11 0x000055904e8759c9 in JOIN::exec (this=this@entry=0x7f4e1c012dd8) at /data/src/10.3/sql/sql_select.cc:3834
#12 0x000055904e875b0f in mysql_select (thd=thd@entry=0x7f4e1c0009a8, tables=0x7f4e1c011898, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f4e1c012db0, unit=0x7f4e1c004698, select_lex=0x7f4e1c004e08) at /data/src/10.3/sql/sql_select.cc:4239
#13 0x000055904e876527 in handle_select (thd=thd@entry=0x7f4e1c0009a8, lex=lex@entry=0x7f4e1c0045d0, result=result@entry=0x7f4e1c012db0, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/src/10.3/sql/sql_select.cc:385
#14 0x000055904e73f4b4 in execute_sqlcom_select (thd=0x7f4e1c0009a8, all_tables=0x7f4e1c011898) at /data/src/10.3/sql/sql_parse.cc:6547
#15 0x000055904e8203c3 in mysql_execute_command (thd=0x7f4e1c0009a8) at /data/src/10.3/sql/sql_parse.cc:3768
#16 0x000055904e822a39 in mysql_parse (thd=0x7f4e1c0009a8, rawbuf=<optimized out>, length=34, parser_state=0x7f4e2c240630, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/src/10.3/sql/sql_parse.cc:8091
#17 0x000055904e825d8e in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f4e1c0009a8, packet=packet@entry=0x7f4e1c009319 "", packet_length=packet_length@entry=34, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.3/sql/sql_parse.cc:1850
#18 0x000055904e826430 in do_command (thd=0x7f4e1c0009a8) at /data/src/10.3/sql/sql_parse.cc:1395
#19 0x000055904e8f7c54 in do_handle_one_connection (connect=connect@entry=0x559050d45b18) at /data/src/10.3/sql/sql_connect.cc:1402
#20 0x000055904e8f7df4 in handle_one_connection (arg=arg@entry=0x559050d45b18) at /data/src/10.3/sql/sql_connect.cc:1308
#21 0x000055904ebdb4e4 in pfs_spawn_thread (arg=0x559050db6958) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#22 0x00007f4e33b57494 in start_thread (arg=0x7f4e2c241700) at pthread_create.c:333
#23 0x00007f4e3215893f in clone () from /lib/x86_64-linux-gnu/libc.so.6
Reproducible with at least MyISAM and InnoDB.
On a debug build, it causes the same assertion failure as in the description.