[MDEV-16808] 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 Created: 2018-07-24  Updated: 2023-12-13

Status: Confirmed
Project: MariaDB Server
Component/s: Optimizer, Server
Affects Version/s: 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2

Type: Bug Priority: Critical
Reporter: Alice Sherepa Assignee: Igor Babaev
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by MDEV-18433 Assertion `0' failed in Field_blob_... Closed
is duplicated by MDEV-21005 Assertion `0' failed in Field_blob_co... Closed
is duplicated by MDEV-32009 mariadb server crash Closed
Relates
relates to MDEV-13540 Server crashes in copy or Assertion `... Closed

 Description   

--source include/have_innodb.inc
set join_cache_level=3;
 
CREATE TABLE t1 (col_blob text)engine=innodb;
CREATE TABLE t2 (col_blob text COMPRESSED)engine=innodb;
 
SELECT * FROM t1 JOIN t2 USING ( col_blob );

 
mysqld: /git/10.3/sql/field.h:3831: virtual Field* Field_blob_compressed::new_key_field(MEM_ROOT*, TABLE*, uchar*, uint32, uchar*, uint): Assertion `0' failed.
180724 12:21:59 [ERROR] mysqld got signal 6 ;
 
Server version: 10.3.9-MariaDB-debug-log
 
stack_bottom = 0x7f573900bc70 thread_stack 0x49000
/usr/lib/x86_64-linux-gnu/libasan.so.2(+0x4a077)[0x7f5753ab8077]
mysys/stacktrace.c:269(my_print_stacktrace)[0x5617a87a81dc]
sql/signal_handler.cc:168(handle_fatal_signal)[0x5617a74c5331]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f5752350390]
linux/raise.c:54(__GI_raise)[0x7f5751709428]
stdlib/abort.c:91(__GI_abort)[0x7f575170b02a]
assert/assert.c:92(__assert_fail_base)[0x7f5751701bd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f5751701c82]
/git/10.3/sql/mysqld(+0x16a88d5)[0x5617a74a68d5]
sql/sql_select.h:1839(store_key::store_key(THD*, Field*, unsigned char*, unsigned char*, unsigned int))[0x5617a6f60663]
sql/sql_select.h:1896(store_key_field::store_key_field(THD*, Field*, unsigned char*, unsigned char*, unsigned int, Field*, char const*))[0x5617a6f60bdd]
sql/sql_select.cc:9972(get_store_key(THD*, keyuse_t*, unsigned long long, st_key_part_info*, unsigned char*, unsigned int))[0x5617a6ee1099]
sql/sql_select.cc:9890(create_ref_for_key(JOIN*, st_join_table*, keyuse_t*, bool, unsigned long long))[0x5617a6ee016b]
sql/sql_select.cc:9565(JOIN::get_best_combination())[0x5617a6edd455]
sql/sql_select.cc:1928(JOIN::optimize_stage2())[0x5617a6ea460a]
sql/sql_select.cc:1907(JOIN::optimize_inner())[0x5617a6ea43ae]
sql/sql_select.cc:1448(JOIN::optimize())[0x5617a6ea02ae]
sql/sql_select.cc:4206(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x5617a6eb9f3d]
sql/sql_select.cc:382(handle_select(THD*, LEX*, select_result*, unsigned long))[0x5617a6e95973]
sql/sql_parse.cc:6542(execute_sqlcom_select(THD*, TABLE_LIST*))[0x5617a6e1b4c4]
sql/sql_parse.cc:3765(mysql_execute_command(THD*))[0x5617a6e09cd7]
sql/sql_parse.cc:8073(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x5617a6e23dd2]
sql/sql_parse.cc:1849(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x5617a6dfeab9]
sql/sql_parse.cc:1392(do_command(THD*))[0x5617a6dfbc51]
sql/sql_connect.cc:1402(do_handle_one_connection(CONNECT*))[0x5617a714b0b6]
sql/sql_connect.cc:1309(handle_one_connection)[0x5617a714aa93]
perfschema/pfs.cc:1864(pfs_spawn_thread)[0x5617a86892e3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f57523466ba]
x86_64/clone.S:111(clone)[0x7f57517db41d]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x62b000000288): SELECT * FROM t1 JOIN t2 USING ( col_blob )
Connection ID (thread ID): 9
Status: NOT_KILLED



 Comments   
Comment by Elena Stepanova [ 2018-12-03 ]

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.

Comment by Roel Van de Paar [ 2020-11-02 ]

USE test;
CREATE TABLE t (c CHAR(0) NOT NULL);
CREATE TABLE u LIKE t;
SET join_cache_level=3;
SELECT t.c,u.c FROM t JOIN u ON t.c=u.c;

Leads to:

10.6.0 5d4599f9750140f92cfdbbe4d292ae1b8dd456f8 (Debug)

mysqld: /test/10.6_dbg/sql/sql_select.cc:10734: bool create_ref_for_key(JOIN*, JOIN_TAB*, KEYUSE*, bool, table_map): Assertion `length > 0' failed.

10.6.0 5d4599f9750140f92cfdbbe4d292ae1b8dd456f8 (Debug)

Core was generated by `/test/MD211020-mariadb-10.6.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[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

Bug confirmed present in:
MariaDB: 10.1.48 (dbg), 10.2.35 (dbg), 10.3.26 (dbg), 10.4.16 (dbg), 10.5.7 (dbg), 10.6.0 (dbg)

Bug confirmed not present in:
MariaDB: 10.1.48 (opt), 10.2.35 (opt), 10.3.26 (opt), 10.4.16 (opt), 10.5.7 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.50 (dbg), 5.6.50 (opt), 5.7.32 (dbg), 5.7.32 (opt), 8.0.22 (dbg), 8.0.22 (opt)

Comment by Roel Van de Paar [ 2020-11-02 ]

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

Comment by Roel Van de Paar [ 2022-03-01 ]

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)

Comment by Roel Van de Paar [ 2023-08-04 ]

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;

Comment by Roel Van de Paar [ 2023-08-30 ]

ASAN/UBSAN does not see any issues.

Generated at Thu Feb 08 08:31:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.