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

Server crash or ASAN heap-buffer-overflow in create_index upon modifying column into a blob

    XMLWordPrintable

Details

    Description

      Note: The failure became possible after MDEV-371, without it ALTER is rejected due to the missing length in the key definition.
      See also MDEV-18708, might be related or have the same root cause.

      --source include/have_innodb.inc
       
      CREATE TABLE t1 ( 
        pk INT,
        a CHAR(100),
        b INT,
        c CHAR(100),
        PRIMARY KEY(pk),
        KEY(a(64)),
        KEY(pk,b),
        KEY(c(64),a(64))
      ) ENGINE=InnoDB;
      ALTER TABLE t1 MODIFY b TEXT;
       
      # Cleanup
      DROP TABLE t1;
      

      10.4 fb01193c

      #2  0x000055e0b56e9e6a in handle_fatal_signal (sig=11) at /data/src/10.4/sql/signal_handler.cc:305
      #3  <signal handler called>
      #4  0x000055e0b5a5306c in create_index (trx=0x7f71d8eae268, form=0x7f71d83c2200, table=0x7f718c061c78, key_num=3) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:11272
      #5  0x000055e0b5a3f1fe in create_table_info_t::create_table (this=0x7f71d83c1ca0, create_fk=true) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:12451
      #6  0x000055e0b5a536e8 in ha_innobase::create (this=0x7f718c05fb78, name=0x7f71d83c494d "./test/#sql-3207_9", form=0x7f71d83c2200, create_info=0x7f71d83c4cd0, file_per_table=true, trx=0x7f71d8eae268) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:12683
      #7  0x000055e0b5a3fad1 in ha_innobase::create (this=0x7f718c05fb78, name=0x7f71d83c494d "./test/#sql-3207_9", form=0x7f71d83c2200, create_info=0x7f71d83c4cd0) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:12736
      #8  0x000055e0b56f8af0 in handler::ha_create (this=0x7f718c05fb78, name=0x7f71d83c494d "./test/#sql-3207_9", form=0x7f71d83c2200, info_arg=0x7f71d83c4cd0) at /data/src/10.4/sql/handler.cc:4816
      #9  0x000055e0b56f9b65 in ha_create_table (thd=0x7f718c000b00, path=0x7f71d83c494d "./test/#sql-3207_9", db=0x7f718c015c38 "test", table_name=0x7f718c015558 "t1", create_info=0x7f71d83c4cd0, frm=0x7f71d83c38a0) at /data/src/10.4/sql/handler.cc:5190
      #10 0x000055e0b549562d in mysql_alter_table (thd=0x7f718c000b00, new_db=0x7f718c005290, new_name=0x7f718c005690, create_info=0x7f71d83c4cd0, table_list=0x7f718c015590, alter_info=0x7f71d83c4c10, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:9976
      #11 0x000055e0b5523922 in Sql_cmd_alter_table::execute (this=0x7f718c015d60, thd=0x7f718c000b00) at /data/src/10.4/sql/sql_alter.cc:499
      #12 0x000055e0b53b4aca in mysql_execute_command (thd=0x7f718c000b00) at /data/src/10.4/sql/sql_parse.cc:6346
      #13 0x000055e0b53b9c72 in mysql_parse (thd=0x7f718c000b00, rawbuf=0x7f718c0154a8 "ALTER TABLE t1 MODIFY b TEXT", length=28, parser_state=0x7f71d83c6180, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8157
      #14 0x000055e0b53a5360 in dispatch_command (command=COM_QUERY, thd=0x7f718c000b00, packet=0x7f718c19fff1 "ALTER TABLE t1 MODIFY b TEXT", packet_length=28, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1829
      #15 0x000055e0b53a3b34 in do_command (thd=0x7f718c000b00) at /data/src/10.4/sql/sql_parse.cc:1358
      #16 0x000055e0b551d837 in do_handle_one_connection (connect=0x55e0b7af1e00) at /data/src/10.4/sql/sql_connect.cc:1399
      #17 0x000055e0b551d5a8 in handle_one_connection (arg=0x55e0b7af1e00) at /data/src/10.4/sql/sql_connect.cc:1302
      #18 0x000055e0b5a14979 in pfs_spawn_thread (arg=0x55e0b7b37ac0) at /data/src/10.4/storage/perfschema/pfs.cc:1862
      #19 0x00007f71e0d74494 in start_thread (arg=0x7f71d83c7700) at pthread_create.c:333
      #20 0x00007f71df15a93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      10.4 fb01193c ASAN

      ==13256==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61900010e4e8 at pc 0x55fc2d0cdb61 bp 0x7f3cb62251f0 sp 0x7f3cb62251e8
      READ of size 8 at 0x61900010e4e8 thread T27
          #0 0x55fc2d0cdb60 in create_index(trx_t*, TABLE const*, dict_table_t*, unsigned int) (/data/bld/10.4-asan-daily/bin/mysqld+0x1fceb60)
          #1 0x55fc2d0a1c85 in create_table_info_t::create_table(bool) /data/src/10.4/storage/innobase/handler/ha_innodb.cc:12451
          #2 0x55fc2d0ceb7d in ha_innobase::create(char const*, TABLE*, HA_CREATE_INFO*, bool, trx_t*) (/data/bld/10.4-asan-daily/bin/mysqld+0x1fcfb7d)
          #3 0x55fc2d0a3087 in ha_innobase::create(char const*, TABLE*, HA_CREATE_INFO*) /data/src/10.4/storage/innobase/handler/ha_innodb.cc:12736
          #4 0x55fc2c8a3b4f in handler::ha_create(char const*, TABLE*, HA_CREATE_INFO*) /data/src/10.4/sql/handler.cc:4816
          #5 0x55fc2c8a6c2e in ha_create_table(THD*, char const*, char const*, char const*, HA_CREATE_INFO*, st_mysql_const_unsigned_lex_string*) /data/src/10.4/sql/handler.cc:5190
          #6 0x55fc2c32fd26 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool) /data/src/10.4/sql/sql_table.cc:9976
          #7 0x55fc2c485b5a in Sql_cmd_alter_table::execute(THD*) /data/src/10.4/sql/sql_alter.cc:499
          #8 0x55fc2c102e7d in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:6346
          #9 0x55fc2c10d87e in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.4/sql/sql_parse.cc:8157
          #10 0x55fc2c0e5a87 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.4/sql/sql_parse.cc:1829
          #11 0x55fc2c0e2888 in do_command(THD*) /data/src/10.4/sql/sql_parse.cc:1358
          #12 0x55fc2c476449 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1399
          #13 0x55fc2c475e42 in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1302
          #14 0x55fc2d040f5e in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #15 0x7f3cc1bd4493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #16 0x7f3cbffba93e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x61900010e4ec is located 0 bytes to the right of 1132-byte region [0x61900010e080,0x61900010e4ec)
      allocated by thread T27 here:
          #0 0x7f3cc1e3e73f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x55fc2d9f0931 in sf_malloc /data/src/10.4/mysys/safemalloc.c:118
          #2 0x55fc2d9c122c in my_malloc /data/src/10.4/mysys/my_malloc.c:101
          #3 0x55fc2d9a0924 in alloc_root /data/src/10.4/mysys/my_alloc.c:250
          #4 0x55fc2c3b6fd0 in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /data/src/10.4/sql/table.cc:3686
          #5 0x55fc2c8a6bb8 in ha_create_table(THD*, char const*, char const*, char const*, HA_CREATE_INFO*, st_mysql_const_unsigned_lex_string*) /data/src/10.4/sql/handler.cc:5183
          #6 0x55fc2c32fd26 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool) /data/src/10.4/sql/sql_table.cc:9976
          #7 0x55fc2c485b5a in Sql_cmd_alter_table::execute(THD*) /data/src/10.4/sql/sql_alter.cc:499
          #8 0x55fc2c102e7d in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:6346
          #9 0x55fc2c10d87e in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.4/sql/sql_parse.cc:8157
          #10 0x55fc2c0e5a87 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.4/sql/sql_parse.cc:1829
          #11 0x55fc2c0e2888 in do_command(THD*) /data/src/10.4/sql/sql_parse.cc:1358
          #12 0x55fc2c476449 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1399
          #13 0x55fc2c475e42 in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1302
          #14 0x55fc2d040f5e in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #15 0x7f3cc1bd4493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
       
      Thread T27 created by T0 here:
          #0 0x7f3cc1e0dbba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x55fc2d041526 in spawn_thread_v1 /data/src/10.4/storage/perfschema/pfs.cc:1912
          #2 0x55fc2be31c96 in inline_mysql_thread_create /data/src/10.4/include/mysql/psi/mysql_thread.h:1268
          #3 0x55fc2be474c0 in create_thread_to_handle_connection(CONNECT*) /data/src/10.4/sql/mysqld.cc:6194
          #4 0x55fc2be47bc5 in create_new_thread(CONNECT*) /data/src/10.4/sql/mysqld.cc:6264
          #5 0x55fc2be47f55 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.4/sql/mysqld.cc:6362
          #6 0x55fc2be48ba1 in handle_connections_sockets() /data/src/10.4/sql/mysqld.cc:6520
          #7 0x55fc2be46cfb in mysqld_main(int, char**) /data/src/10.4/sql/mysqld.cc:5852
          #8 0x55fc2be2fb1f in main /data/src/10.4/sql/main.cc:25
          #9 0x7f3cbfef22b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
       
      SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 create_index(trx_t*, TABLE const*, dict_table_t*, unsigned int)
      Shadow bytes around the buggy address:
        0x0c3280019c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280019c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280019c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280019c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280019c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c3280019c90: 00 00 00 00 00 00 00 00 00 00 00 00 00[04]fa fa
        0x0c3280019ca0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c3280019cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280019cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280019cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c3280019ce0: 00 00 00 00 00 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
        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
        Contiguous container OOB:fc
        ASan internal:           fe
      ==13256==ABORTING
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.