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

MariaDB ASAN Unknown Crash in Item_func_to_char::parse_format_string

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.9.0, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL)
    • 10.6, 10.11
    • None
    • None
    •   Linux jie-2 5.4.143-1-pve #1 SMP PVE 5.4.143-1 (Tue, 28 Sep 2021 09:10:37 +0200) x86_64 x86_64 x86_64 GNU/Linux

    Description

      PoC:

      CREATE TABLE maximum_value(
        start_value int NOT NULL, increment int NOT NULL, cache_size varchar(1) NOT NULL,
        PRIMARY KEY (start_value), INDEX maximum_value (cache_size, increment)
      ) ENGINE=ARIA;
      INSERT INTO maximum_value VALUES 
        (1,9,'x'), (2,5,'g'), (3,1,'o'), (4,0,'g'), (5,1,'cache_size'),
        (6,190,'cache_size'), (7,6,'x'), (8,3,'c'), (9,4,'z'), (10,3,'increment'),
        (11,186,'x'), (12,1,'g'), (13,8,'q'), (14,226,'cache_size'), (15,133,'p');
      select to_char('2000-11-11', cache_size) from maximum_value;
      

      report (compiled with ASAN):

      =================================================================
      ==3729==ERROR: AddressSanitizer: unknown-crash on address 0x619000065eda at pc 0x0000019c0bc8 bp 0x7f1f3b4ddf30 sp 0x7f1f3b4ddf28
      READ of size 1 at 0x619000065eda thread T17
          #0 0x19c0bc7 in Item_func_tochar::parse_format_string(String const*, unsigned int*) /root/mariadb/sql/item_timefunc.cc:2176:18
          #1 0x19c2a49 in Item_func_tochar::val_str(String*) /root/mariadb/sql/item_timefunc.cc:2704:9
          #2 0x1335e49 in Type_handler::Item_send_str(Item*, Protocol*, st_value*) const /root/mariadb/sql/sql_type.cc:7468:19
          #3 0x920511 in Protocol::send_result_set_row(List<Item>*) /root/mariadb/sql/protocol.cc:1328:15
          #4 0xaf9409 in select_send::send_data(List<Item>&) /root/mariadb/sql/sql_class.cc:3060:17
          #5 0xdb5094 in select_result_sink::send_data_with_check(List<Item>&, st_select_lex_unit*, unsigned long long) /root/mariadb/sql/sql_class.h:5612:12
          #6 0xdb5094 in end_send(JOIN*, st_join_table*, bool) /root/mariadb/sql/sql_select.cc:22331:9
          #7 0xe315ff in evaluate_join_record(JOIN*, st_join_table*, int) /root/mariadb/sql/sql_select.cc:21325:11
          #8 0xd4c23d in sub_select(JOIN*, st_join_table*, bool) /root/mariadb/sql/sql_select.cc:21134:9
          #9 0xdc6797 in do_select(JOIN*, Procedure*) /root/mariadb/sql/sql_select.cc:20640:14
          #10 0xdc6797 in JOIN::exec_inner() /root/mariadb/sql/sql_select.cc:4749:50
          #11 0xdc344c in JOIN::exec() /root/mariadb/sql/sql_select.cc:4527:3
          #12 0xd4e4e8 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*) /root/mariadb/sql/sql_select.cc:5007:9
          #13 0xd4d74b in handle_select(THD*, LEX*, select_result*, unsigned long) /root/mariadb/sql/sql_select.cc:543:10
          #14 0xc74410 in execute_sqlcom_select(THD*, TABLE_LIST*) /root/mariadb/sql/sql_parse.cc:6252:12
          #15 0xc609c9 in mysql_execute_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:3943:12
          #16 0xc4a67e in mysql_parse(THD*, char*, unsigned int, Parser_state*) /root/mariadb/sql/sql_parse.cc:8027:18
          #17 0xc41ba9 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /root/mariadb/sql/sql_parse.cc:1894:7
          #18 0xc4b74b in do_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:1402:17
          #19 0x111f9f2 in do_handle_one_connection(CONNECT*, bool) /root/mariadb/sql/sql_connect.cc:1418:11
          #20 0x111f248 in handle_one_connection /root/mariadb/sql/sql_connect.cc:1312:5
          #21 0x1f3f9dd in pfs_spawn_thread /root/mariadb/storage/perfschema/pfs.cc:2201:3
          #22 0x7f1f622a1608 in start_thread /build/glibc-sMfBJT/glibc-2.31/nptl/pthread_create.c:477:8
          #23 0x7f1f61fb7162 in clone /build/glibc-sMfBJT/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
       
      0x619000065eda is located 90 bytes inside of 1040-byte region [0x619000065e80,0x619000066290)
      allocated by thread T17 here:
          #0 0x80f99d in malloc (/usr/local/mysql/bin/mariadbd+0x80f99d)
          #1 0x2a76878 in my_malloc /root/mariadb/mysys/my_malloc.c:90:29
          #2 0x2a5887f in root_alloc /root/mariadb/mysys/my_alloc.c:66:10
          #3 0x2a5887f in alloc_root /root/mariadb/mysys/my_alloc.c:332:29
          #4 0x2a5a13a in strmake_root /root/mariadb/mysys/my_alloc.c:584:12
          #5 0x104b928 in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /root/mariadb/sql/table.cc:4033:20
          #6 0xa8ccd2 in open_table(THD*, TABLE_LIST*, Open_table_context*) /root/mariadb/sql/sql_base.cc:2003:12
          #7 0xa98133 in open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) /root/mariadb/sql/sql_base.cc:3809:14
          #8 0xa98133 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /root/mariadb/sql/sql_base.cc:4292:14
          #9 0xaa1ff6 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /root/mariadb/sql/sql_base.cc:5265:7
          #10 0xb656a1 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /root/mariadb/sql/sql_base.h:509:10
          #11 0xb656a1 in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /root/mariadb/sql/sql_insert.cc:758:9
          #12 0xc68510 in mysql_execute_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:4562:10
          #13 0xc4a67e in mysql_parse(THD*, char*, unsigned int, Parser_state*) /root/mariadb/sql/sql_parse.cc:8027:18
          #14 0xc41ba9 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /root/mariadb/sql/sql_parse.cc:1894:7
          #15 0xc4b74b in do_command(THD*, bool) /root/mariadb/sql/sql_parse.cc:1402:17
          #16 0x111f9f2 in do_handle_one_connection(CONNECT*, bool) /root/mariadb/sql/sql_connect.cc:1418:11
          #17 0x111f248 in handle_one_connection /root/mariadb/sql/sql_connect.cc:1312:5
          #18 0x1f3f9dd in pfs_spawn_thread /root/mariadb/storage/perfschema/pfs.cc:2201:3
          #19 0x7f1f622a1608 in start_thread /build/glibc-sMfBJT/glibc-2.31/nptl/pthread_create.c:477:8
       
      Thread T17 created by T0 here:
          #0 0x7f9cfc in pthread_create (/usr/local/mysql/bin/mariadbd+0x7f9cfc)
          #1 0x1f3fd39 in my_thread_create(unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /root/mariadb/storage/perfschema/my_thread.h:52:10
          #2 0x1f3fd39 in pfs_spawn_thread_v1 /root/mariadb/storage/perfschema/pfs.cc:2252:15
          #3 0x85cef4 in inline_mysql_thread_create(unsigned int, unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /root/mariadb/include/mysql/psi/mysql_thread.h:1139:11
          #4 0x85cef4 in create_thread_to_handle_connection(CONNECT*) /root/mariadb/sql/mysqld.cc:5975:19
          #5 0x85e72a in create_new_thread(CONNECT*) /root/mariadb/sql/mysqld.cc:6034:3
          #6 0x85e72a in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /root/mariadb/sql/mysqld.cc:6096:5
          #7 0x85a34c in handle_connections_sockets() /root/mariadb/sql/mysqld.cc:6220:9
          #8 0x84e9ef in mysqld_main(int, char**) /root/mariadb/sql/mysqld.cc:5870:3
          #9 0x7f1f61ebc0b2 in __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:308:16
       
      SUMMARY: AddressSanitizer: unknown-crash /root/mariadb/sql/item_timefunc.cc:2176:18 in Item_func_tochar::parse_format_string(String const*, unsigned int*)
      Shadow bytes around the buggy address:
        0x0c3280004b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280004b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280004ba0: 00 00 00 00 00 00 fa fa fa fa fa fa fa fa fa fa
        0x0c3280004bb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c3280004bc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0c3280004bd0: 00 00 00 00 00 00 f7 00 06 f7 00[02]00 02 f7 00
        0x0c3280004be0: 00 00 00 f7 00 00 00 00 00 00 00 00 00 00 f7 00
        0x0c3280004bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280004c00: 00 00 00 00 00 00 00 00 00 f7 00 00 00 00 00 00
        0x0c3280004c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280004c20: 00 00 00 00 f7 00 00 00 00 00 00 00 00 00 00 00
      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
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        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
        Shadow gap:              cc
      ==3729==ABORTING
      

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              fuboat Jingzhou Fu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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