[MDEV-25490] Memory leaks after INSERT .. RETURNING with subquery Created: 2021-04-22  Updated: 2023-06-08  Resolved: 2023-06-08

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Insert
Affects Version/s: 10.5, 10.6
Fix Version/s: 10.5.18, 10.6.11, 10.8.6, 10.9.4, 10.10.2

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-28515 Assertion `field->table == table' fai... Closed

 Description   

CREATE TABLE t (a INT);
INSERT INTO t SELECT 1 FROM DUAL WHERE 2 IN (SELECT 3 UNION SELECT 4) RETURNING a;
 
# Cleanup
DROP TABLE t;

10.5 9abc6fd7 non-debug ASAN

Warning: Memory not freed: 120
 
=================================================================
==2557170==ERROR: LeakSanitizer: detected memory leaks
 
Indirect leak of 2936 byte(s) in 1 object(s) allocated from:
    #0 0x7f401a53bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x560726a693ac in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x560726a5525d in alloc_root /data/src/10.5/mysys/my_alloc.c:244
    #3 0x560726a5563f in multi_alloc_root /data/src/10.5/mysys/my_alloc.c:317
    #4 0x5607250ab736 in Create_tmp_table::start(THD*, TMP_TABLE_PARAM*, st_mysql_const_lex_string const*) /data/src/10.5/sql/sql_select.cc:18508
    #5 0x5607250c9b6e in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19349
    #6 0x5607252545fd in select_unit::create_result_table(THD*, List<Item>*, bool, unsigned long long, st_mysql_const_lex_string const*, bool, bool, bool, unsigned int) /data/src/10.5/sql/sql_union.cc:329
    #7 0x56072526dac8 in st_select_lex_unit::prepare(TABLE_LIST*, select_result*, unsigned long long) /data/src/10.5/sql/sql_union.cc:1755
    #8 0x5607259c88b1 in subselect_union_engine::prepare(THD*) /data/src/10.5/sql/item_subselect.cc:3881
    #9 0x5607259c6eab in Item_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:289
    #10 0x5607259c7f29 in Item_in_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:3525
    #11 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:988
    #12 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:986
    #13 0x560724e5f86c in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /data/src/10.5/sql/item.h:992
    #14 0x560724e5f86c in Item::fix_fields_if_needed_for_bool(THD*, Item**) /data/src/10.5/sql/item.h:996
    #15 0x560724e5f86c in setup_conds(THD*, TABLE_LIST*, List<TABLE_LIST>&, Item**) /data/src/10.5/sql/sql_base.cc:8384
    #16 0x5607250f6eb0 in setup_without_group /data/src/10.5/sql/sql_select.cc:722
    #17 0x5607250f6eb0 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.5/sql/sql_select.cc:1274
    #18 0x560725140256 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4726
    #19 0x560725140eef in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #20 0x560724fdb2b2 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4774
    #21 0x560724f9518c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8101
    #22 0x560724fc273a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #23 0x560724fc99fa in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #24 0x56072536b6ec in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #25 0x56072536c284 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #26 0x560725f676c8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #27 0x7f4019f3c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
Indirect leak of 1488 byte(s) in 1 object(s) allocated from:
    #0 0x7f401a53bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x560726a693ac in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x56072613e289 in heap_create /data/src/10.5/storage/heap/hp_create.c:162
    #3 0x56072612cbd5 in ha_heap::open(char const*, int, unsigned int) /data/src/10.5/storage/heap/ha_heap.cc:104
    #4 0x5607256d6ef3 in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /data/src/10.5/sql/handler.cc:2983
    #5 0x5607250b0177 in open_tmp_table(TABLE*) /data/src/10.5/sql/sql_select.cc:19552
    #6 0x5607250c8b8d in Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool) /data/src/10.5/sql/sql_select.cc:19257
    #7 0x5607250c9bcd in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19351
    #8 0x5607252545fd in select_unit::create_result_table(THD*, List<Item>*, bool, unsigned long long, st_mysql_const_lex_string const*, bool, bool, bool, unsigned int) /data/src/10.5/sql/sql_union.cc:329
    #9 0x56072526dac8 in st_select_lex_unit::prepare(TABLE_LIST*, select_result*, unsigned long long) /data/src/10.5/sql/sql_union.cc:1755
    #10 0x5607259c88b1 in subselect_union_engine::prepare(THD*) /data/src/10.5/sql/item_subselect.cc:3881
    #11 0x5607259c6eab in Item_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:289
    #12 0x5607259c7f29 in Item_in_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:3525
    #13 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:988
    #14 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:986
    #15 0x560724e5f86c in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /data/src/10.5/sql/item.h:992
    #16 0x560724e5f86c in Item::fix_fields_if_needed_for_bool(THD*, Item**) /data/src/10.5/sql/item.h:996
    #17 0x560724e5f86c in setup_conds(THD*, TABLE_LIST*, List<TABLE_LIST>&, Item**) /data/src/10.5/sql/sql_base.cc:8384
    #18 0x5607250f6eb0 in setup_without_group /data/src/10.5/sql/sql_select.cc:722
    #19 0x5607250f6eb0 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.5/sql/sql_select.cc:1274
    #20 0x560725140256 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4726
    #21 0x560725140eef in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #22 0x560724fdb2b2 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4774
    #23 0x560724f9518c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8101
    #24 0x560724fc273a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #25 0x560724fc99fa in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #26 0x56072536b6ec in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #27 0x56072536c284 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #28 0x560725f676c8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #29 0x7f4019f3c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
Indirect leak of 1336 byte(s) in 1 object(s) allocated from:
    #0 0x7f401a53bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x560726a693ac in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x560726a5525d in alloc_root /data/src/10.5/mysys/my_alloc.c:244
    #3 0x5607261290c3 in Sql_alloc::operator new(unsigned long, st_mem_root*) /data/src/10.5/sql/sql_alloc.h:39
    #4 0x5607261290c3 in heap_create_handler /data/src/10.5/storage/heap/ha_heap.cc:65
    #5 0x5607256cea0c in get_new_handler(TABLE_SHARE*, st_mem_root*, handlerton*) /data/src/10.5/sql/handler.cc:375
    #6 0x5607250c56cb in Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool) /data/src/10.5/sql/sql_select.cc:18837
    #7 0x5607250c9bcd in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19351
    #8 0x5607252545fd in select_unit::create_result_table(THD*, List<Item>*, bool, unsigned long long, st_mysql_const_lex_string const*, bool, bool, bool, unsigned int) /data/src/10.5/sql/sql_union.cc:329
    #9 0x56072526dac8 in st_select_lex_unit::prepare(TABLE_LIST*, select_result*, unsigned long long) /data/src/10.5/sql/sql_union.cc:1755
    #10 0x5607259c88b1 in subselect_union_engine::prepare(THD*) /data/src/10.5/sql/item_subselect.cc:3881
    #11 0x5607259c6eab in Item_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:289
    #12 0x5607259c7f29 in Item_in_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:3525
    #13 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:988
    #14 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:986
    #15 0x560724e5f86c in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /data/src/10.5/sql/item.h:992
    #16 0x560724e5f86c in Item::fix_fields_if_needed_for_bool(THD*, Item**) /data/src/10.5/sql/item.h:996
    #17 0x560724e5f86c in setup_conds(THD*, TABLE_LIST*, List<TABLE_LIST>&, Item**) /data/src/10.5/sql/sql_base.cc:8384
    #18 0x5607250f6eb0 in setup_without_group /data/src/10.5/sql/sql_select.cc:722
    #19 0x5607250f6eb0 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.5/sql/sql_select.cc:1274
    #20 0x560725140256 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4726
    #21 0x560725140eef in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #22 0x560724fdb2b2 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4774
    #23 0x560724f9518c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8101
    #24 0x560724fc273a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #25 0x560724fc99fa in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #26 0x56072536b6ec in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #27 0x56072536c284 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #28 0x560725f676c8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #29 0x7f4019f3c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
Indirect leak of 1008 byte(s) in 1 object(s) allocated from:
    #0 0x7f401a53bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x560726a693ac in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x560726a5525d in alloc_root /data/src/10.5/mysys/my_alloc.c:244
    #3 0x5607254e1aeb in Field::operator new(unsigned long, st_mem_root*) /data/src/10.5/sql/field.h:761
    #4 0x5607254a517e in Type_handler_long::make_table_field_from_def(TABLE_SHARE*, st_mem_root*, st_mysql_const_lex_string const*, Record_addr const&, Bit_addr const&, Column_definition_attributes const*, unsigned int) const /data/src/10.5/sql/sql_type.cc:8129
    #5 0x56072549639a in Type_handler_int_result::make_table_field(st_mem_root*, st_mysql_const_lex_string const*, Record_addr const&, Type_all_attributes const&, TABLE_SHARE*) const /data/src/10.5/sql/sql_type.cc:3561
    #6 0x5607254cfc71 in Type_handler::make_and_init_table_field(st_mem_root*, st_mysql_const_lex_string const*, Record_addr const&, Type_all_attributes const&, TABLE*) const /data/src/10.5/sql/sql_type.cc:3546
    #7 0x56072576bc23 in Item_type_holder::create_tmp_field_ex(st_mem_root*, TABLE*, Tmp_field_src*, Tmp_field_param const*) /data/src/10.5/sql/item.h:7384
    #8 0x5607250aa5a4 in create_tmp_field(TABLE*, Item*, Item***, Field**, Field**, bool, bool, bool, bool) /data/src/10.5/sql/sql_select.cc:18225
    #9 0x5607250acd07 in Create_tmp_table::add_fields(THD*, TABLE*, TMP_TABLE_PARAM*, List<Item>&) /data/src/10.5/sql/sql_select.cc:18713
    #10 0x5607250c9ba0 in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19350
    #11 0x5607252545fd in select_unit::create_result_table(THD*, List<Item>*, bool, unsigned long long, st_mysql_const_lex_string const*, bool, bool, bool, unsigned int) /data/src/10.5/sql/sql_union.cc:329
    #12 0x56072526dac8 in st_select_lex_unit::prepare(TABLE_LIST*, select_result*, unsigned long long) /data/src/10.5/sql/sql_union.cc:1755
    #13 0x5607259c88b1 in subselect_union_engine::prepare(THD*) /data/src/10.5/sql/item_subselect.cc:3881
    #14 0x5607259c6eab in Item_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:289
    #15 0x5607259c7f29 in Item_in_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:3525
    #16 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:988
    #17 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:986
    #18 0x560724e5f86c in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /data/src/10.5/sql/item.h:992
    #19 0x560724e5f86c in Item::fix_fields_if_needed_for_bool(THD*, Item**) /data/src/10.5/sql/item.h:996
    #20 0x560724e5f86c in setup_conds(THD*, TABLE_LIST*, List<TABLE_LIST>&, Item**) /data/src/10.5/sql/sql_base.cc:8384
    #21 0x5607250f6eb0 in setup_without_group /data/src/10.5/sql/sql_select.cc:722
    #22 0x5607250f6eb0 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.5/sql/sql_select.cc:1274
    #23 0x560725140256 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4726
    #24 0x560725140eef in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #25 0x560724fdb2b2 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4774
    #26 0x560724f9518c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8101
    #27 0x560724fc273a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #28 0x560724fc99fa in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #29 0x56072536b6ec in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #30 0x56072536c284 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #31 0x560725f676c8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #32 0x7f4019f3c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
Indirect leak of 768 byte(s) in 1 object(s) allocated from:
    #0 0x7f401a53bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x560726a693ac in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x56072613621a in heap_open_from_share /data/src/10.5/storage/heap/hp_open.c:33
    #3 0x56072612ccdf in ha_heap::open(char const*, int, unsigned int) /data/src/10.5/storage/heap/ha_heap.cc:111
    #4 0x5607256d6ef3 in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /data/src/10.5/sql/handler.cc:2983
    #5 0x5607250b0177 in open_tmp_table(TABLE*) /data/src/10.5/sql/sql_select.cc:19552
    #6 0x5607250c8b8d in Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool) /data/src/10.5/sql/sql_select.cc:19257
    #7 0x5607250c9bcd in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19351
    #8 0x5607252545fd in select_unit::create_result_table(THD*, List<Item>*, bool, unsigned long long, st_mysql_const_lex_string const*, bool, bool, bool, unsigned int) /data/src/10.5/sql/sql_union.cc:329
    #9 0x56072526dac8 in st_select_lex_unit::prepare(TABLE_LIST*, select_result*, unsigned long long) /data/src/10.5/sql/sql_union.cc:1755
    #10 0x5607259c88b1 in subselect_union_engine::prepare(THD*) /data/src/10.5/sql/item_subselect.cc:3881
    #11 0x5607259c6eab in Item_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:289
    #12 0x5607259c7f29 in Item_in_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:3525
    #13 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:988
    #14 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:986
    #15 0x560724e5f86c in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /data/src/10.5/sql/item.h:992
    #16 0x560724e5f86c in Item::fix_fields_if_needed_for_bool(THD*, Item**) /data/src/10.5/sql/item.h:996
    #17 0x560724e5f86c in setup_conds(THD*, TABLE_LIST*, List<TABLE_LIST>&, Item**) /data/src/10.5/sql/sql_base.cc:8384
    #18 0x5607250f6eb0 in setup_without_group /data/src/10.5/sql/sql_select.cc:722
    #19 0x5607250f6eb0 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.5/sql/sql_select.cc:1274
    #20 0x560725140256 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4726
    #21 0x560725140eef in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #22 0x560724fdb2b2 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4774
    #23 0x560724f9518c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8101
    #24 0x560724fc273a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #25 0x560724fc99fa in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #26 0x56072536b6ec in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #27 0x56072536c284 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #28 0x560725f676c8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #29 0x7f4019f3c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
Indirect leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7f401a53bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x560726a693ac in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x560726a69962 in my_strdup /data/src/10.5/mysys/my_malloc.c:233
    #3 0x56072613ec72 in heap_create /data/src/10.5/storage/heap/hp_create.c:226
    #4 0x56072612cbd5 in ha_heap::open(char const*, int, unsigned int) /data/src/10.5/storage/heap/ha_heap.cc:104
    #5 0x5607256d6ef3 in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /data/src/10.5/sql/handler.cc:2983
    #6 0x5607250b0177 in open_tmp_table(TABLE*) /data/src/10.5/sql/sql_select.cc:19552
    #7 0x5607250c8b8d in Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool) /data/src/10.5/sql/sql_select.cc:19257
    #8 0x5607250c9bcd in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19351
    #9 0x5607252545fd in select_unit::create_result_table(THD*, List<Item>*, bool, unsigned long long, st_mysql_const_lex_string const*, bool, bool, bool, unsigned int) /data/src/10.5/sql/sql_union.cc:329
    #10 0x56072526dac8 in st_select_lex_unit::prepare(TABLE_LIST*, select_result*, unsigned long long) /data/src/10.5/sql/sql_union.cc:1755
    #11 0x5607259c88b1 in subselect_union_engine::prepare(THD*) /data/src/10.5/sql/item_subselect.cc:3881
    #12 0x5607259c6eab in Item_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:289
    #13 0x5607259c7f29 in Item_in_subselect::fix_fields(THD*, Item**) /data/src/10.5/sql/item_subselect.cc:3525
    #14 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:988
    #15 0x560724e5f86c in Item::fix_fields_if_needed(THD*, Item**) /data/src/10.5/sql/item.h:986
    #16 0x560724e5f86c in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /data/src/10.5/sql/item.h:992
    #17 0x560724e5f86c in Item::fix_fields_if_needed_for_bool(THD*, Item**) /data/src/10.5/sql/item.h:996
    #18 0x560724e5f86c in setup_conds(THD*, TABLE_LIST*, List<TABLE_LIST>&, Item**) /data/src/10.5/sql/sql_base.cc:8384
    #19 0x5607250f6eb0 in setup_without_group /data/src/10.5/sql/sql_select.cc:722
    #20 0x5607250f6eb0 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /data/src/10.5/sql/sql_select.cc:1274
    #21 0x560725140256 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4726
    #22 0x560725140eef in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #23 0x560724fdb2b2 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4774
    #24 0x560724f9518c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8101
    #25 0x560724fc273a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #26 0x560724fc99fa in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #27 0x56072536b6ec in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #28 0x56072536c284 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #29 0x560725f676c8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #30 0x7f4019f3c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
SUMMARY: AddressSanitizer: 7656 byte(s) leaked in 6 allocation(s).
210422 15:44:38 [ERROR] mysqld got signal 6 ;
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.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
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.
 
Server version: 10.5.10-MariaDB-log
read_buffer_size=131072
max_used_connections=1
thread_count=0
Thread pointer: 0x0
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...
stack_bottom = 0x0 thread_stack 0x5fc00
??:0(__interceptor_tcgetattr)[0x7f401a49ad30]
mysys/stacktrace.c:213(my_print_stacktrace)[0x560726a72916]
sql/signal_handler.cc:221(handle_fatal_signal)[0x5607256c5e44]
sigaction.c:0(__restore_rt)[0x7f4019f483c0]
??:0(gsignal)[0x7f4019a3418b]
??:0(abort)[0x7f4019a13859]
??:0(__sanitizer_set_report_fd)[0x7f401a5596a2]
??:0(__sanitizer_get_module_and_offset_for_pc)[0x7f401a56424c]
??:0(__lsan_do_recoverable_leak_check)[0x7f401a569b9c]
??:0(__lsan_enable)[0x7f401a5693dd]
??:0(__cxa_finalize)[0x7f4019a3815e]
/lib/x86_64-linux-gnu/libasan.so.5(+0x22be7)[0x7f401a450be7]
The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file...
Working directory at /dev/shm/var_auto_femX/mysqld.1/data
Resource Limits:
Fatal signal 11 while backtracing

10.5 9abc6fd7

mariadbd: /data/src/10.5/sql/sql_class.cc:1760: virtual THD::~THD(): Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed.
210422 15:45:46 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f008cdf0f36 in __GI___assert_fail (assertion=0x559ed5f26500 "status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory", file=0x559ed5f25fd0 "/data/src/10.5/sql/sql_class.cc", line=1760, function=0x559ed5f264a6 "virtual THD::~THD()") at assert.c:101
#8  0x0000559ed50d6a34 in THD::~THD (this=0x7f006c000db8, __in_chrg=<optimized out>) at /data/src/10.5/sql/sql_class.cc:1760
#9  0x0000559ed50d6c6e in THD::~THD (this=0x7f006c000db8, __in_chrg=<optimized out>) at /data/src/10.5/sql/sql_class.cc:1766
#10 0x0000559ed52fdd80 in do_handle_one_connection (connect=0x0, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1451
#11 0x0000559ed52fd93a in handle_one_connection (arg=0x559ed8822c18) at /data/src/10.5/sql/sql_connect.cc:1312
#12 0x0000559ed5861ca3 in pfs_spawn_thread (arg=0x559ed891b978) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#13 0x00007f008d308609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#14 0x00007f008cedc293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
 
Query (0x0): (null)
Connection ID (thread ID): 7
Status: KILL_CONNECTION

Reproducible on 10.5, 10.6.
Not applicable to previous versions due to the use of INSERT .. RETURNING.



 Comments   
Comment by Elena Stepanova [ 2021-07-05 ]

Without UNION:

CREATE TABLE t1 (f INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f INT);
INSERT INTO t2 SELECT f FROM (SELECT DISTINCT f FROM t1) AS sq LIMIT 0 RETURNING *;
 
# Cleanup
DROP TABLE t1, t2;

10.5 f0f47cbc

==1409535==ERROR: LeakSanitizer: detected memory leaks
 
Indirect leak of 2976 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d3163bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55ba64b9ab1c in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x55ba64b869cd in alloc_root /data/src/10.5/mysys/my_alloc.c:244
    #3 0x55ba64b86daf in multi_alloc_root /data/src/10.5/mysys/my_alloc.c:317
    #4 0x55ba631dddd6 in Create_tmp_table::start(THD*, TMP_TABLE_PARAM*, st_mysql_const_lex_string const*) /data/src/10.5/sql/sql_select.cc:18515
    #5 0x55ba631fc20e in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19356
    #6 0x55ba63230cab in JOIN::create_postjoin_aggr_table(st_join_table*, List<Item>*, st_order*, bool, bool, bool) /data/src/10.5/sql/sql_select.cc:3791
    #7 0x55ba63233ef1 in JOIN::make_aggr_tables_info() /data/src/10.5/sql/sql_select.cc:3391
    #8 0x55ba6325be9a in JOIN::optimize_stage2() /data/src/10.5/sql/sql_select.cc:3035
    #9 0x55ba63267f0c in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2320
    #10 0x55ba6327064c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1666
    #11 0x55ba62ff7489 in mysql_derived_optimize /data/src/10.5/sql/sql_derived.cc:1048
    #12 0x55ba62ff5815 in mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int) /data/src/10.5/sql/sql_derived.cc:200
    #13 0x55ba63267dea in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2126
    #14 0x55ba6327064c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1666
    #15 0x55ba632708ac in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4747
    #16 0x55ba6327358f in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #17 0x55ba6310c009 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4771
    #18 0x55ba630c674c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8096
    #19 0x55ba630f3f1a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #20 0x55ba630fb14a in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #21 0x55ba6349f96c in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #22 0x55ba634a0504 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #23 0x55ba6409e898 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #24 0x7f8d3103c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
Indirect leak of 1336 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d3163bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55ba64b9ab1c in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x55ba64b869cd in alloc_root /data/src/10.5/mysys/my_alloc.c:244
    #3 0x55ba64260353 in Sql_alloc::operator new(unsigned long, st_mem_root*) /data/src/10.5/sql/sql_alloc.h:39
    #4 0x55ba64260353 in heap_create_handler /data/src/10.5/storage/heap/ha_heap.cc:65
    #5 0x55ba63804c7c in get_new_handler(TABLE_SHARE*, st_mem_root*, handlerton*) /data/src/10.5/sql/handler.cc:375
    #6 0x55ba631f7d6b in Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool) /data/src/10.5/sql/sql_select.cc:18844
    #7 0x55ba631fc26d in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19358
    #8 0x55ba63230cab in JOIN::create_postjoin_aggr_table(st_join_table*, List<Item>*, st_order*, bool, bool, bool) /data/src/10.5/sql/sql_select.cc:3791
    #9 0x55ba63233ef1 in JOIN::make_aggr_tables_info() /data/src/10.5/sql/sql_select.cc:3391
    #10 0x55ba6325be9a in JOIN::optimize_stage2() /data/src/10.5/sql/sql_select.cc:3035
    #11 0x55ba63267f0c in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2320
    #12 0x55ba6327064c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1666
    #13 0x55ba62ff7489 in mysql_derived_optimize /data/src/10.5/sql/sql_derived.cc:1048
    #14 0x55ba62ff5815 in mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int) /data/src/10.5/sql/sql_derived.cc:200
    #15 0x55ba63267dea in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2126
    #16 0x55ba6327064c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1666
    #17 0x55ba632708ac in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4747
    #18 0x55ba6327358f in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #19 0x55ba6310c009 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4771
    #20 0x55ba630c674c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8096
    #21 0x55ba630f3f1a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #22 0x55ba630fb14a in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #23 0x55ba6349f96c in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #24 0x55ba634a0504 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #25 0x55ba6409e898 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #26 0x7f8d3103c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
Indirect leak of 1008 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d3163bbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55ba64b9ab1c in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x55ba64b869cd in alloc_root /data/src/10.5/mysys/my_alloc.c:244
    #3 0x55ba64b87709 in memdup_root /data/src/10.5/mysys/my_alloc.c:479
    #4 0x55ba63780701 in Field::make_new_field(st_mem_root*, TABLE*, bool) /data/src/10.5/sql/field.cc:2477
    #5 0x55ba637a2afa in Field::create_tmp_field(st_mem_root*, TABLE*, bool) /data/src/10.5/sql/field.cc:2535
    #6 0x55ba631db2e4 in Item_field::create_tmp_field_from_item_field(st_mem_root*, TABLE*, Item_ref*, Tmp_field_param const*) /data/src/10.5/sql/sql_select.cc:18060
    #7 0x55ba631dbb19 in Item_field::create_tmp_field_ex(st_mem_root*, TABLE*, Tmp_field_src*, Tmp_field_param const*) /data/src/10.5/sql/sql_select.cc:18077
    #8 0x55ba631dcc44 in create_tmp_field(TABLE*, Item*, Item***, Field**, Field**, bool, bool, bool, bool) /data/src/10.5/sql/sql_select.cc:18232
    #9 0x55ba631df3a7 in Create_tmp_table::add_fields(THD*, TABLE*, TMP_TABLE_PARAM*, List<Item>&) /data/src/10.5/sql/sql_select.cc:18720
    #10 0x55ba631fc240 in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19357
    #11 0x55ba63230cab in JOIN::create_postjoin_aggr_table(st_join_table*, List<Item>*, st_order*, bool, bool, bool) /data/src/10.5/sql/sql_select.cc:3791
    #12 0x55ba63233ef1 in JOIN::make_aggr_tables_info() /data/src/10.5/sql/sql_select.cc:3391
    #13 0x55ba6325be9a in JOIN::optimize_stage2() /data/src/10.5/sql/sql_select.cc:3035
    #14 0x55ba63267f0c in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2320
    #15 0x55ba6327064c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1666
    #16 0x55ba62ff7489 in mysql_derived_optimize /data/src/10.5/sql/sql_derived.cc:1048
    #17 0x55ba62ff5815 in mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int) /data/src/10.5/sql/sql_derived.cc:200
    #18 0x55ba63267dea in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2126
    #19 0x55ba6327064c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1666
    #20 0x55ba632708ac in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4747
    #21 0x55ba6327358f in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:443
    #22 0x55ba6310c009 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4771
    #23 0x55ba630c674c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8096
    #24 0x55ba630f3f1a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #25 0x55ba630fb14a in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #26 0x55ba6349f96c in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1410
    #27 0x55ba634a0504 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #28 0x55ba6409e898 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #29 0x7f8d3103c608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
 
SUMMARY: AddressSanitizer: 5320 byte(s) leaked in 3 allocation(s).
210705 21:26:47 [ERROR] mysqld got signal 6 ;
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.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
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.
 
Server version: 10.5.12-MariaDB-log
read_buffer_size=131072
max_used_connections=1
thread_count=0
Thread pointer: 0x0
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...
stack_bottom = 0x0 thread_stack 0x5fc00
??:0(__interceptor_tcgetattr)[0x7f8d3159ad30]
mysys/stacktrace.c:213(my_print_stacktrace)[0x55ba64ba4086]
sql/signal_handler.cc:221(handle_fatal_signal)[0x55ba637fc0b4]
sigaction.c:0(__restore_rt)[0x7f8d310483c0]
??:0(gsignal)[0x7f8d30b3318b]
??:0(abort)[0x7f8d30b12859]
??:0(__sanitizer_set_report_fd)[0x7f8d316596a2]
??:0(__sanitizer_get_module_and_offset_for_pc)[0x7f8d3166424c]
??:0(__lsan_do_recoverable_leak_check)[0x7f8d31669b9c]
??:0(__lsan_enable)[0x7f8d316693dd]
??:0(__cxa_finalize)[0x7f8d30b3715e]
/lib/x86_64-linux-gnu/libasan.so.5(+0x22be7)[0x7f8d31550be7]
The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file...
Working directory at /dev/shm/var_auto_swZi/mysqld.1/data
Resource Limits:
Fatal signal 11 while backtracing

Comment by Elena Stepanova [ 2021-10-14 ]

Different stack traces:

CREATE TABLE t1 (pk INT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f INT);
INSERT INTO t2 SELECT pk FROM t1 WHERE 1 NOT IN (SELECT pk FROM t1) RETURNING f;

10.5 bd1573b0

==2674934==ERROR: LeakSanitizer: detected memory leaks
 
Direct leak of 1784 byte(s) in 1 object(s) allocated from:
    #0 0x7f87df8c5bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55c6fd03d7ec in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x55c6fcff3d90 in init_dynamic_array2 /data/src/10.5/mysys/array.c:71
    #3 0x55c6fb761030 in JOIN::reoptimize(Item*, unsigned long long, JOIN::Join_plan_state*) /data/src/10.5/sql/sql_select.cc:28279
    #4 0x55c6fba8760d in JOIN::choose_subquery_plan(unsigned long long) /data/src/10.5/sql/opt_subselect.cc:6513
    #5 0x55c6fb7806b5 in make_join_statistics /data/src/10.5/sql/sql_select.cc:5694
    #6 0x55c6fb7806b5 in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2296
    #7 0x55c6fb7813ec in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1668
    #8 0x55c6fbffdf8e in subselect_single_select_engine::exec() /data/src/10.5/sql/item_subselect.cc:3993
    #9 0x55c6fbffc502 in Item_subselect::exec() /data/src/10.5/sql/item_subselect.cc:836
    #10 0x55c6fbffc938 in Item_in_subselect::val_bool() /data/src/10.5/sql/item_subselect.cc:1929
    #11 0x55c6fbdffb50 in Item_in_optimizer::val_int() /data/src/10.5/sql/item_cmpfunc.cc:1653
    #12 0x55c6fbdffb50 in Item_in_optimizer::val_int() /data/src/10.5/sql/item_cmpfunc.cc:1561
    #13 0x55c6fbd51a86 in Item_cache_int::cache_value() /data/src/10.5/sql/item.cc:9957
    #14 0x55c6fbdbd7e0 in Item_cache_wrapper::cache() /data/src/10.5/sql/item.cc:8743
    #15 0x55c6fbda5e57 in Item_cache_wrapper::val_bool() /data/src/10.5/sql/item.cc:8929
    #16 0x55c6fbda5e57 in Item_cache_wrapper::val_bool() /data/src/10.5/sql/item.cc:8912
    #17 0x55c6fbdcf175 in Item_func_not::val_int() /data/src/10.5/sql/item_cmpfunc.cc:202
    #18 0x55c6fb7876a7 in JOIN::exec_inner() /data/src/10.5/sql/sql_select.cc:4412
    #19 0x55c6fb789ef6 in JOIN::exec() /data/src/10.5/sql/sql_select.cc:4296
    #20 0x55c6fb7817c6 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4773
    #21 0x55c6fb78433f in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:444
    #22 0x55c6fb61c74b in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4770
    #23 0x55c6fb5d627c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8100
    #24 0x55c6fb603f7d in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #25 0x55c6fb60b63a in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #26 0x55c6fb9b0aac in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1418
    #27 0x55c6fb9b1654 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #28 0x55c6fc53ccb8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
    #29 0x7f87df1fc608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477

--source include/have_innodb.inc
 
CREATE TABLE t1 (pk INT, c VARCHAR(1), PRIMARY KEY (pk)) ENGINE=InnoDB;
CREATE TABLE t2 (f INT) ENGINE=InnoDB;
REPLACE INTO t2 SELECT pk FROM t1 WHERE 'x' NOT IN (SELECT t1a.c FROM t1 AS t1a JOIN t1 t1b WHERE t1a.pk != t1b.pk) RETURNING f;

 
Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7f5a0ea60bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x561635a147ec in my_malloc /data/src/10.5/mysys/my_malloc.c:90
    #2 0x56163440a8c4 in JOIN_CACHE::alloc_buffer() /data/src/10.5/sql/sql_join_cache.cc:940
    #3 0x56163440c6af in JOIN_CACHE::init(bool) /data/src/10.5/sql/sql_join_cache.cc:1073
    #4 0x56163413e74f in JOIN::init_join_cache_and_keyread() /data/src/10.5/sql/sql_select.cc:29718
    #5 0x561634143c48 in JOIN::optimize_stage2() /data/src/10.5/sql/sql_select.cc:3040
    #6 0x56163414fcac in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2322
    #7 0x5616341583ec in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1668
    #8 0x5616349d4f8e in subselect_single_select_engine::exec() /data/src/10.5/sql/item_subselect.cc:3993
    #9 0x5616349d3502 in Item_subselect::exec() /data/src/10.5/sql/item_subselect.cc:836
    #10 0x5616349d3938 in Item_in_subselect::val_bool() /data/src/10.5/sql/item_subselect.cc:1929
    #11 0x5616347d6b50 in Item_in_optimizer::val_int() /data/src/10.5/sql/item_cmpfunc.cc:1653
    #12 0x5616347d6b50 in Item_in_optimizer::val_int() /data/src/10.5/sql/item_cmpfunc.cc:1561
    #13 0x561634728a86 in Item_cache_int::cache_value() /data/src/10.5/sql/item.cc:9957
    #14 0x5616347947e0 in Item_cache_wrapper::cache() /data/src/10.5/sql/item.cc:8743
    #15 0x56163477ce57 in Item_cache_wrapper::val_bool() /data/src/10.5/sql/item.cc:8929
    #16 0x56163477ce57 in Item_cache_wrapper::val_bool() /data/src/10.5/sql/item.cc:8912
    #17 0x5616347a6175 in Item_func_not::val_int() /data/src/10.5/sql/item_cmpfunc.cc:202
    #18 0x56163415e6a7 in JOIN::exec_inner() /data/src/10.5/sql/sql_select.cc:4412
    #19 0x561634160ef6 in JOIN::exec() /data/src/10.5/sql/sql_select.cc:4296
    #20 0x5616341587c6 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4773
    #21 0x56163415b33f in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:444
    #22 0x561633ff374b in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4770
    #23 0x561633fad27c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8100
    #24 0x561633fdaf7d in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
    #25 0x561633fe263a in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1370
    #26 0x561634387aac in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1418
    #27 0x561634388654 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
    #28 0x561634f13cb8 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201

Comment by Elena Stepanova [ 2023-06-08 ]

The failure disappeared after this commit in 10.5.18:

commit 7865c8c9a2fba7444c29af3fcece32f7f83f71be (HEAD)
Author: Rucha Deodhar
Date:   Mon Sep 26 13:29:10 2022 +0530
 
    Crash in INSERT...SELECT..RETURNING with subquery

Generated at Thu Feb 08 09:38:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.