Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20619

AddressSanitizer: heap-use-after-free in my_strnncollsp_simple or my_strnncoll_binary upon SELECT with partitions and virtual columns

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
       
      CREATE TABLE t1 ( 
          pk INT,
          f1 INT,
          f2 INT AS (f1) VIRTUAL,
          f3 TEXT,
          f4 TINYTEXT AS (f3),
          f5 INT DEFAULT 0,
          PRIMARY KEY (pk),
          KEY (f2,f5)
      ) ENGINE=MyISAM;
      INSERT IGNORE INTO t1 (pk,f3,f1) VALUES
          (1,REPEAT('a',49602),4),
          (2,REPEAT('b',28272),5),
          (3,REPEAT('c',34639),6);
       
      ALTER TABLE t1 PARTITION BY KEY() PARTITIONS 5;
       
      SELECT * FROM t1 WHERE f2 != 8 AND f4 = 'foo' ORDER BY f5;
       
      # Cleanup
      DROP TABLE t1;
      

      10.2 ASAN fb3e3a6a

      ==21543==ERROR: AddressSanitizer: heap-use-after-free on address 0x62c000040270 at pc 0x564761a3293c bp 0x7fe014ac0370 sp 0x7fe014ac0368
      READ of size 1 at 0x62c000040270 thread T5
          #0 0x564761a3293b in my_strnncollsp_simple /data/src/10.2/strings/ctype-simple.c:182
          #1 0x564760548911 in sortcmp(String const*, String const*, charset_info_st const*) /data/src/10.2/sql/sql_string.cc:804
          #2 0x5647609f03d8 in Arg_comparator::compare_string() /data/src/10.2/sql/item_cmpfunc.cc:833
          #3 0x564760a2c3d3 in Arg_comparator::compare() /data/src/10.2/sql/item_cmpfunc.h:87
          #4 0x5647609fb681 in Item_func_eq::val_int() /data/src/10.2/sql/item_cmpfunc.cc:1799
          #5 0x564760980c28 in Item::val_bool() /data/src/10.2/sql/item.cc:112
          #6 0x564760a1a18e in Item_cond_and::val_int() /data/src/10.2/sql/item_cmpfunc.cc:5082
          #7 0x5647605cf5bc in SQL_SELECT::skip_record(THD*) /data/src/10.2/sql/opt_range.h:1632
          #8 0x564760942ae5 in find_all_keys /data/src/10.2/sql/filesort.cc:835
          #9 0x56476093f022 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /data/src/10.2/sql/filesort.cc:274
          #10 0x56476049695d in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /data/src/10.2/sql/sql_select.cc:22039
          #11 0x5647604876f8 in st_join_table::sort_table() /data/src/10.2/sql/sql_select.cc:19804
          #12 0x564760486d1b in join_init_read_record(st_join_table*) /data/src/10.2/sql/sql_select.cc:19745
          #13 0x5647604809c8 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18836
          #14 0x56476047ef9b in do_select /data/src/10.2/sql/sql_select.cc:18383
          #15 0x56476041f9ea in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3623
          #16 0x56476041d7b7 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3418
          #17 0x564760420a2d in 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*) /data/src/10.2/sql/sql_select.cc:3818
          #18 0x5647603ffd81 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.2/sql/sql_select.cc:361
          #19 0x564760385b6a in execute_sqlcom_select /data/src/10.2/sql/sql_parse.cc:6225
          #20 0x564760373ebf in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:3532
          #21 0x56476038e4aa in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7759
          #22 0x56476036a6aa in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1831
          #23 0x5647603676c0 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1384
          #24 0x5647606a07c9 in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #25 0x5647606a0199 in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #26 0x5647618d4502 in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1862
          #27 0x7fe0203924a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
          #28 0x7fe01e8dad0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)
       
      0x62c000040270 is located 112 bytes inside of 28396-byte region [0x62c000040200,0x62c0000470ec)
      freed by thread T5 here:
          #0 0x7fe020669a10 in free (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1a10)
          #1 0x5647619da365 in free_memory /data/src/10.2/mysys/safemalloc.c:279
          #2 0x5647619d99df in sf_free /data/src/10.2/mysys/safemalloc.c:197
          #3 0x5647619aa7eb in my_free /data/src/10.2/mysys/my_malloc.c:218
          #4 0x5647601913b1 in String::free() /data/src/10.2/sql/sql_string.h:347
          #5 0x5647601cf036 in String::set(char const*, unsigned int, charset_info_st const*) /data/src/10.2/sql/sql_string.h:270
          #6 0x564760911c40 in Field_blob::val_str(String*, String*) /data/src/10.2/sql/field.cc:8344
          #7 0x5647601b3b5f in Field::val_str(String*) /data/src/10.2/sql/field.h:869
          #8 0x56476092fe2c in Field_blob::store_field(Field*) /data/src/10.2/sql/field.h:3357
          #9 0x56476093cd0b in field_conv_incompatible /data/src/10.2/sql/field_conv.cc:831
          #10 0x56476093cda8 in field_conv(Field*, Field*) /data/src/10.2/sql/field_conv.cc:842
          #11 0x5647609ae752 in save_field_in_field /data/src/10.2/sql/item.cc:6288
          #12 0x5647609aec62 in Item_field::save_in_field(Field*, bool) /data/src/10.2/sql/item.cc:6334
          #13 0x564760616893 in TABLE::update_virtual_fields(handler*, enum_vcol_update_mode) /data/src/10.2/sql/table.cc:7679
          #14 0x5647609604f5 in handler::ha_index_next(unsigned char*) /data/src/10.2/sql/handler.cc:2768
          #15 0x564760970c43 in handler::read_range_next() /data/src/10.2/sql/handler.cc:5505
          #16 0x56476192d445 in ha_partition::handle_ordered_next(unsigned char*, bool) /data/src/10.2/sql/ha_partition.cc:6374
          #17 0x5647619296be in ha_partition::read_range_next() /data/src/10.2/sql/ha_partition.cc:5832
          #18 0x56476073a7cb in handler::multi_range_read_next(void**) /data/src/10.2/sql/multi_range_read.cc:270
          #19 0x564760ca4375 in QUICK_RANGE_SELECT::get_next() /data/src/10.2/sql/opt_range.cc:11459
          #20 0x564760942598 in find_all_keys /data/src/10.2/sql/filesort.cc:781
          #21 0x56476093f022 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /data/src/10.2/sql/filesort.cc:274
          #22 0x56476049695d in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /data/src/10.2/sql/sql_select.cc:22039
          #23 0x5647604876f8 in st_join_table::sort_table() /data/src/10.2/sql/sql_select.cc:19804
          #24 0x564760486d1b in join_init_read_record(st_join_table*) /data/src/10.2/sql/sql_select.cc:19745
          #25 0x5647604809c8 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18836
          #26 0x56476047ef9b in do_select /data/src/10.2/sql/sql_select.cc:18383
          #27 0x56476041f9ea in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3623
          #28 0x56476041d7b7 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3418
          #29 0x564760420a2d in 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*) /data/src/10.2/sql/sql_select.cc:3818
       
      previously allocated by thread T5 here:
          #0 0x7fe020669d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x5647619d93b6 in sf_malloc /data/src/10.2/mysys/safemalloc.c:118
          #2 0x5647619a9f4e in my_malloc /data/src/10.2/mysys/my_malloc.c:101
          #3 0x564760544369 in String::realloc_raw(unsigned long) /data/src/10.2/sql/sql_string.cc:102
          #4 0x5647601914ca in String::realloc(unsigned long) /data/src/10.2/sql/sql_string.h:363
          #5 0x564760544aff in String::copy() /data/src/10.2/sql/sql_string.cc:158
          #6 0x56476092ff35 in Field_blob::store_field(Field*) /data/src/10.2/sql/field.h:3360
          #7 0x56476093cd0b in field_conv_incompatible /data/src/10.2/sql/field_conv.cc:831
          #8 0x56476093cda8 in field_conv(Field*, Field*) /data/src/10.2/sql/field_conv.cc:842
          #9 0x5647609ae752 in save_field_in_field /data/src/10.2/sql/item.cc:6288
          #10 0x5647609aec62 in Item_field::save_in_field(Field*, bool) /data/src/10.2/sql/item.cc:6334
          #11 0x564760616893 in TABLE::update_virtual_fields(handler*, enum_vcol_update_mode) /data/src/10.2/sql/table.cc:7679
          #12 0x56476095f541 in handler::ha_index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function) /data/src/10.2/sql/handler.cc:2718
          #13 0x564760970826 in handler::read_range_first(st_key_range const*, st_key_range const*, bool, bool) /data/src/10.2/sql/handler.cc:5458
          #14 0x56476192bc6c in ha_partition::handle_ordered_index_scan(unsigned char*, bool) /data/src/10.2/sql/ha_partition.cc:6180
          #15 0x564761927c51 in ha_partition::common_index_read(unsigned char*, bool) /data/src/10.2/sql/ha_partition.cc:5527
          #16 0x564761929465 in ha_partition::read_range_first(st_key_range const*, st_key_range const*, bool, bool) /data/src/10.2/sql/ha_partition.cc:5810
          #17 0x56476073aa4c in handler::multi_range_read_next(void**) /data/src/10.2/sql/multi_range_read.cc:298
          #18 0x564760ca4375 in QUICK_RANGE_SELECT::get_next() /data/src/10.2/sql/opt_range.cc:11459
          #19 0x564760942598 in find_all_keys /data/src/10.2/sql/filesort.cc:781
          #20 0x56476093f022 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /data/src/10.2/sql/filesort.cc:274
          #21 0x56476049695d in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /data/src/10.2/sql/sql_select.cc:22039
          #22 0x5647604876f8 in st_join_table::sort_table() /data/src/10.2/sql/sql_select.cc:19804
          #23 0x564760486d1b in join_init_read_record(st_join_table*) /data/src/10.2/sql/sql_select.cc:19745
          #24 0x5647604809c8 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18836
          #25 0x56476047ef9b in do_select /data/src/10.2/sql/sql_select.cc:18383
          #26 0x56476041f9ea in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3623
          #27 0x56476041d7b7 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3418
          #28 0x564760420a2d in 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*) /data/src/10.2/sql/sql_select.cc:3818
          #29 0x5647603ffd81 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.2/sql/sql_select.cc:361
       
      Thread T5 created by T0 here:
          #0 0x7fe0205d8f59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
          #1 0x5647618d493e in spawn_thread_v1 /data/src/10.2/storage/perfschema/pfs.cc:1912
          #2 0x56476016fbb2 in inline_mysql_thread_create /data/src/10.2/include/mysql/psi/mysql_thread.h:1239
          #3 0x5647601841ae in create_thread_to_handle_connection(CONNECT*) /data/src/10.2/sql/mysqld.cc:6508
          #4 0x564760184891 in create_new_thread /data/src/10.2/sql/mysqld.cc:6578
          #5 0x5647601858a9 in handle_connections_sockets() /data/src/10.2/sql/mysqld.cc:6853
          #6 0x564760183719 in mysqld_main(int, char**) /data/src/10.2/sql/mysqld.cc:6127
          #7 0x56476016e53f in main /data/src/10.2/sql/main.cc:25
          #8 0x7fe01e8122e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
       
      SUMMARY: AddressSanitizer: heap-use-after-free /data/src/10.2/strings/ctype-simple.c:182 in my_strnncollsp_simple
      Shadow bytes around the buggy address:
        0x0c587ffffff0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0c5880000040: fd fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd
        0x0c5880000050: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000060: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000070: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000090: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07 
        Heap left redzone:       fa
        Heap right redzone:      fb
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack partial redzone:   f4
        Stack after return:      f5
        Stack use after scope:   f8
        Global redzone:          f9
        Global init order:       f6
        Poisoned by user:        f7
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      ==21543==ABORTING
      

      Similar test case, the only difference is TINYBLOB instead of TINYTEXT as a type of the virtual column:

      --source include/have_partition.inc
       
      CREATE TABLE t1 ( 
          pk INT,
          f1 INT,
          f2 INT AS (f1) VIRTUAL,
          f3 TEXT,
          f4 TINYBLOB AS (f3),
          f5 INT DEFAULT 0,
          PRIMARY KEY (pk),
          KEY (f2,f5)
      ) ENGINE=MyISAM;
      INSERT IGNORE INTO t1 (pk,f3,f1) VALUES
          (1,REPEAT('a',49602),4),
          (2,REPEAT('b',28272),5),
          (3,REPEAT('c',34639),6);
       
      ALTER TABLE t1 PARTITION BY KEY() PARTITIONS 5;
       
      SELECT * FROM t1 WHERE f2 != 8 AND f4 = 'foo' ORDER BY f5;
       
      # Cleanup
      DROP TABLE t1;
      

      10.2 ASAN fb3e3a6a

      ==1666==ERROR: AddressSanitizer: heap-use-after-free on address 0x62c000040270 at pc 0x7f1a2dfbe6ff bp 0x7f1a22445340 sp 0x7f1a22444af0
      READ of size 3 at 0x62c000040270 thread T5
          #0 0x7f1a2dfbe6fe  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8d6fe)
          #1 0x5597bcc9a960 in my_strnncoll_binary /data/src/10.2/strings/ctype-bin.c:85
          #2 0x5597bcc9a9e3 in my_strnncollsp_binary /data/src/10.2/strings/ctype-bin.c:124
          #3 0x5597bb7cb911 in sortcmp(String const*, String const*, charset_info_st const*) /data/src/10.2/sql/sql_string.cc:804
          #4 0x5597bbc733d8 in Arg_comparator::compare_string() /data/src/10.2/sql/item_cmpfunc.cc:833
          #5 0x5597bbcaf3d3 in Arg_comparator::compare() /data/src/10.2/sql/item_cmpfunc.h:87
          #6 0x5597bbc7e681 in Item_func_eq::val_int() /data/src/10.2/sql/item_cmpfunc.cc:1799
          #7 0x5597bbc03c28 in Item::val_bool() /data/src/10.2/sql/item.cc:112
          #8 0x5597bbc9d18e in Item_cond_and::val_int() /data/src/10.2/sql/item_cmpfunc.cc:5082
          #9 0x5597bb8525bc in SQL_SELECT::skip_record(THD*) /data/src/10.2/sql/opt_range.h:1632
          #10 0x5597bbbc5ae5 in find_all_keys /data/src/10.2/sql/filesort.cc:835
          #11 0x5597bbbc2022 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /data/src/10.2/sql/filesort.cc:274
          #12 0x5597bb71995d in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /data/src/10.2/sql/sql_select.cc:22039
          #13 0x5597bb70a6f8 in st_join_table::sort_table() /data/src/10.2/sql/sql_select.cc:19804
          #14 0x5597bb709d1b in join_init_read_record(st_join_table*) /data/src/10.2/sql/sql_select.cc:19745
          #15 0x5597bb7039c8 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18836
          #16 0x5597bb701f9b in do_select /data/src/10.2/sql/sql_select.cc:18383
          #17 0x5597bb6a29ea in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3623
          #18 0x5597bb6a07b7 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3418
          #19 0x5597bb6a3a2d in 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*) /data/src/10.2/sql/sql_select.cc:3818
          #20 0x5597bb682d81 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.2/sql/sql_select.cc:361
          #21 0x5597bb608b6a in execute_sqlcom_select /data/src/10.2/sql/sql_parse.cc:6225
          #22 0x5597bb5f6ebf in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:3532
          #23 0x5597bb6114aa in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7759
          #24 0x5597bb5ed6aa in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1831
          #25 0x5597bb5ea6c0 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1384
          #26 0x5597bb9237c9 in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #27 0x5597bb923199 in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #28 0x5597bcb57502 in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1862
          #29 0x7f1a2dd1b4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
          #30 0x7f1a2c263d0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)
       
      0x62c000040270 is located 112 bytes inside of 28396-byte region [0x62c000040200,0x62c0000470ec)
      freed by thread T5 here:
          #0 0x7f1a2dff2a10 in free (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1a10)
          #1 0x5597bcc5d365 in free_memory /data/src/10.2/mysys/safemalloc.c:279
          #2 0x5597bcc5c9df in sf_free /data/src/10.2/mysys/safemalloc.c:197
          #3 0x5597bcc2d7eb in my_free /data/src/10.2/mysys/my_malloc.c:218
          #4 0x5597bb4143b1 in String::free() /data/src/10.2/sql/sql_string.h:347
          #5 0x5597bb452036 in String::set(char const*, unsigned int, charset_info_st const*) /data/src/10.2/sql/sql_string.h:270
          #6 0x5597bbb94c40 in Field_blob::val_str(String*, String*) /data/src/10.2/sql/field.cc:8344
          #7 0x5597bb436b5f in Field::val_str(String*) /data/src/10.2/sql/field.h:869
          #8 0x5597bbbb2e2c in Field_blob::store_field(Field*) /data/src/10.2/sql/field.h:3357
          #9 0x5597bbbbfd0b in field_conv_incompatible /data/src/10.2/sql/field_conv.cc:831
          #10 0x5597bbbbfda8 in field_conv(Field*, Field*) /data/src/10.2/sql/field_conv.cc:842
          #11 0x5597bbc31752 in save_field_in_field /data/src/10.2/sql/item.cc:6288
          #12 0x5597bbc31c62 in Item_field::save_in_field(Field*, bool) /data/src/10.2/sql/item.cc:6334
          #13 0x5597bb899893 in TABLE::update_virtual_fields(handler*, enum_vcol_update_mode) /data/src/10.2/sql/table.cc:7679
          #14 0x5597bbbe34f5 in handler::ha_index_next(unsigned char*) /data/src/10.2/sql/handler.cc:2768
          #15 0x5597bbbf3c43 in handler::read_range_next() /data/src/10.2/sql/handler.cc:5505
          #16 0x5597bcbb0445 in ha_partition::handle_ordered_next(unsigned char*, bool) /data/src/10.2/sql/ha_partition.cc:6374
          #17 0x5597bcbac6be in ha_partition::read_range_next() /data/src/10.2/sql/ha_partition.cc:5832
          #18 0x5597bb9bd7cb in handler::multi_range_read_next(void**) /data/src/10.2/sql/multi_range_read.cc:270
          #19 0x5597bbf27375 in QUICK_RANGE_SELECT::get_next() /data/src/10.2/sql/opt_range.cc:11459
          #20 0x5597bbbc5598 in find_all_keys /data/src/10.2/sql/filesort.cc:781
          #21 0x5597bbbc2022 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /data/src/10.2/sql/filesort.cc:274
          #22 0x5597bb71995d in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /data/src/10.2/sql/sql_select.cc:22039
          #23 0x5597bb70a6f8 in st_join_table::sort_table() /data/src/10.2/sql/sql_select.cc:19804
          #24 0x5597bb709d1b in join_init_read_record(st_join_table*) /data/src/10.2/sql/sql_select.cc:19745
          #25 0x5597bb7039c8 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18836
          #26 0x5597bb701f9b in do_select /data/src/10.2/sql/sql_select.cc:18383
          #27 0x5597bb6a29ea in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3623
          #28 0x5597bb6a07b7 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3418
          #29 0x5597bb6a3a2d in 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*) /data/src/10.2/sql/sql_select.cc:3818
       
      previously allocated by thread T5 here:
          #0 0x7f1a2dff2d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x5597bcc5c3b6 in sf_malloc /data/src/10.2/mysys/safemalloc.c:118
          #2 0x5597bcc2cf4e in my_malloc /data/src/10.2/mysys/my_malloc.c:101
          #3 0x5597bb7c7369 in String::realloc_raw(unsigned long) /data/src/10.2/sql/sql_string.cc:102
          #4 0x5597bb4144ca in String::realloc(unsigned long) /data/src/10.2/sql/sql_string.h:363
          #5 0x5597bb7c7aff in String::copy() /data/src/10.2/sql/sql_string.cc:158
          #6 0x5597bbbb2f35 in Field_blob::store_field(Field*) /data/src/10.2/sql/field.h:3360
          #7 0x5597bbbbfd0b in field_conv_incompatible /data/src/10.2/sql/field_conv.cc:831
          #8 0x5597bbbbfda8 in field_conv(Field*, Field*) /data/src/10.2/sql/field_conv.cc:842
          #9 0x5597bbc31752 in save_field_in_field /data/src/10.2/sql/item.cc:6288
          #10 0x5597bbc31c62 in Item_field::save_in_field(Field*, bool) /data/src/10.2/sql/item.cc:6334
          #11 0x5597bb899893 in TABLE::update_virtual_fields(handler*, enum_vcol_update_mode) /data/src/10.2/sql/table.cc:7679
          #12 0x5597bbbe2541 in handler::ha_index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function) /data/src/10.2/sql/handler.cc:2718
          #13 0x5597bbbf3826 in handler::read_range_first(st_key_range const*, st_key_range const*, bool, bool) /data/src/10.2/sql/handler.cc:5458
          #14 0x5597bcbaec6c in ha_partition::handle_ordered_index_scan(unsigned char*, bool) /data/src/10.2/sql/ha_partition.cc:6180
          #15 0x5597bcbaac51 in ha_partition::common_index_read(unsigned char*, bool) /data/src/10.2/sql/ha_partition.cc:5527
          #16 0x5597bcbac465 in ha_partition::read_range_first(st_key_range const*, st_key_range const*, bool, bool) /data/src/10.2/sql/ha_partition.cc:5810
          #17 0x5597bb9bda4c in handler::multi_range_read_next(void**) /data/src/10.2/sql/multi_range_read.cc:298
          #18 0x5597bbf27375 in QUICK_RANGE_SELECT::get_next() /data/src/10.2/sql/opt_range.cc:11459
          #19 0x5597bbbc5598 in find_all_keys /data/src/10.2/sql/filesort.cc:781
          #20 0x5597bbbc2022 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /data/src/10.2/sql/filesort.cc:274
          #21 0x5597bb71995d in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /data/src/10.2/sql/sql_select.cc:22039
          #22 0x5597bb70a6f8 in st_join_table::sort_table() /data/src/10.2/sql/sql_select.cc:19804
          #23 0x5597bb709d1b in join_init_read_record(st_join_table*) /data/src/10.2/sql/sql_select.cc:19745
          #24 0x5597bb7039c8 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18836
          #25 0x5597bb701f9b in do_select /data/src/10.2/sql/sql_select.cc:18383
          #26 0x5597bb6a29ea in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3623
          #27 0x5597bb6a07b7 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3418
          #28 0x5597bb6a3a2d in 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*) /data/src/10.2/sql/sql_select.cc:3818
          #29 0x5597bb682d81 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.2/sql/sql_select.cc:361
       
      Thread T5 created by T0 here:
          #0 0x7f1a2df61f59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
          #1 0x5597bcb5793e in spawn_thread_v1 /data/src/10.2/storage/perfschema/pfs.cc:1912
          #2 0x5597bb3f2bb2 in inline_mysql_thread_create /data/src/10.2/include/mysql/psi/mysql_thread.h:1239
          #3 0x5597bb4071ae in create_thread_to_handle_connection(CONNECT*) /data/src/10.2/sql/mysqld.cc:6508
          #4 0x5597bb407891 in create_new_thread /data/src/10.2/sql/mysqld.cc:6578
          #5 0x5597bb4088a9 in handle_connections_sockets() /data/src/10.2/sql/mysqld.cc:6853
          #6 0x5597bb406719 in mysqld_main(int, char**) /data/src/10.2/sql/mysqld.cc:6127
          #7 0x5597bb3f153f in main /data/src/10.2/sql/main.cc:25
          #8 0x7f1a2c19b2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
       
      SUMMARY: AddressSanitizer: heap-use-after-free (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8d6fe) 
      Shadow bytes around the buggy address:
        0x0c587ffffff0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5880000030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0c5880000040: fd fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd
        0x0c5880000050: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000060: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000070: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5880000090: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07 
        Heap left redzone:       fa
        Heap right redzone:      fb
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack partial redzone:   f4
        Stack after return:      f5
        Stack use after scope:   f8
        Global redzone:          f9
        Global init order:       f6
        Poisoned by user:        f7
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      ==1666==ABORTING
      

      Reproducible on 10.2+.
      The test case uses MyISAM, but similar failures were observed with more complicated test cases using InnoDB.
      No obvious immediate effect on a non-ASAN build.

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.