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

ASAN heap-use-after-free in ha_maria::info / ha_sequence::info

    XMLWordPrintable

Details

    Description

      CREATE SEQUENCE s ENGINE=Aria;
      SELECT SETVAL(s,1), SETVAL(s,2);
      ALTER TABLE s CHANGE COLUMN IF EXISTS x x INT;
      SHOW TABLE STATUS;
       
      # Cleanup
      DROP SEQUENCE s;
      

      10.3 7060b032

      ==25659==ERROR: AddressSanitizer: heap-use-after-free on address 0x6290000e62c0 at pc 0x562e931a8f1d bp 0x7f2f1d02ec80 sp 0x7f2f1d02ec78
      READ of size 4 at 0x6290000e62c0 thread T5
          #0 0x562e931a8f1c in ha_maria::info(unsigned int) /data/src/10.3/storage/maria/ha_maria.cc:2446
          #1 0x562e935b3e8e in ha_sequence::info(unsigned int) /data/src/10.3/sql/ha_sequence.cc:291
          #2 0x562e91fb6635 in get_schema_tables_record /data/src/10.3/sql/sql_show.cc:5549
          #3 0x562e91faebb9 in fill_schema_table_by_open /data/src/10.3/sql/sql_show.cc:4650
          #4 0x562e91fb21dd in get_all_tables(THD*, TABLE_LIST*, Item*) /data/src/10.3/sql/sql_show.cc:5253
          #5 0x562e91fe5279 in get_schema_tables_result(JOIN*, enum_schema_table_state) /data/src/10.3/sql/sql_show.cc:8847
          #6 0x562e91ed876a in JOIN::exec_inner() /data/src/10.3/sql/sql_select.cc:4005
          #7 0x562e91ed6ae3 in JOIN::exec() /data/src/10.3/sql/sql_select.cc:3836
          #8 0x562e91ed9f52 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.3/sql/sql_select.cc:4241
          #9 0x562e91eb4d9b in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.3/sql/sql_select.cc:373
          #10 0x562e91e3a108 in execute_sqlcom_select /data/src/10.3/sql/sql_parse.cc:6562
          #11 0x562e91e28ba9 in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:3818
          #12 0x562e91e42cc7 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:8105
          #13 0x562e91e1d479 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1858
          #14 0x562e91e1a430 in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1403
          #15 0x562e9217fca6 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1402
          #16 0x562e9217f682 in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #17 0x562e9352aafb in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1862
          #18 0x7f2f28a5a4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
          #19 0x7f2f26fa2d0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)
       
      0x6290000e62c0 is located 192 bytes inside of 18396-byte region [0x6290000e6200,0x6290000ea9dc)
      freed by thread T5 here:
          #0 0x7f2f28d31a10 in free (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1a10)
          #1 0x562e936500bc in free_memory /data/src/10.3/mysys/safemalloc.c:279
          #2 0x562e9364f75e in sf_free /data/src/10.3/mysys/safemalloc.c:197
          #3 0x562e93621cb8 in my_free /data/src/10.3/mysys/my_malloc.c:223
          #4 0x562e932f8f55 in maria_close /data/src/10.3/storage/maria/ma_close.c:258
          #5 0x562e9319eb31 in ha_maria::close() /data/src/10.3/storage/maria/ha_maria.cc:1190
          #6 0x562e935b54a7 in ha_sequence::close() /data/src/10.3/sql/ha_sequence.h:135
          #7 0x562e9250b80e in handler::ha_close() /data/src/10.3/sql/handler.cc:2800
          #8 0x562e920c9afe in closefrm(TABLE*) /data/src/10.3/sql/table.cc:3593
          #9 0x562e92328db5 in intern_close_table /data/src/10.3/sql/table_cache.cc:222
          #10 0x562e9232901c in tc_remove_table /data/src/10.3/sql/table_cache.cc:260
          #11 0x562e9232a2e1 in tc_release_table(TABLE*) /data/src/10.3/sql/table_cache.cc:474
          #12 0x562e91cd1bf0 in close_thread_table(THD*, TABLE**) /data/src/10.3/sql/sql_base.cc:920
          #13 0x562e91cd1351 in close_thread_tables(THD*) /data/src/10.3/sql/sql_base.cc:862
          #14 0x562e91e386bf in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:6383
          #15 0x562e91e42cc7 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:8105
          #16 0x562e91e1d479 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1858
          #17 0x562e91e1a430 in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1403
          #18 0x562e9217fca6 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1402
          #19 0x562e9217f682 in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #20 0x562e9352aafb in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1862
          #21 0x7f2f28a5a4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
       
      previously allocated by thread T5 here:
          #0 0x7f2f28d31d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x562e9364f15e in sf_malloc /data/src/10.3/mysys/safemalloc.c:118
          #2 0x562e936213ff in my_malloc /data/src/10.3/mysys/my_malloc.c:101
          #3 0x562e935fff7d in my_multi_malloc /data/src/10.3/mysys/mulalloc.c:51
          #4 0x562e932369d4 in maria_clone_internal /data/src/10.3/storage/maria/ma_open.c:117
          #5 0x562e9323f060 in maria_open /data/src/10.3/storage/maria/ma_open.c:1056
          #6 0x562e9319dbf1 in ha_maria::open(char const*, int, unsigned int) /data/src/10.3/storage/maria/ha_maria.cc:1116
          #7 0x562e935b1dc8 in ha_sequence::open(char const*, int, unsigned int) /data/src/10.3/sql/ha_sequence.cc:84
          #8 0x562e9250a94e in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /data/src/10.3/sql/handler.cc:2734
          #9 0x562e920c8c06 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.3/sql/table.cc:3495
          #10 0x562e91cd60e3 in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/src/10.3/sql/sql_base.cc:1979
          #11 0x562e91cdd9f4 in open_and_process_table /data/src/10.3/sql/sql_base.cc:3666
          #12 0x562e91ce013d in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, Sroutine_hash_entry**, unsigned int, Prelocking_strategy*) /data/src/10.3/sql/sql_base.cc:4162
          #13 0x562e91ccd7de in open_tables /data/src/10.3/sql/sql_base.h:253
          #14 0x562e91ce48ed in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /data/src/10.3/sql/sql_base.cc:5039
          #15 0x562e91c58f69 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/src/10.3/sql/sql_base.h:513
          #16 0x562e91e396f0 in execute_sqlcom_select /data/src/10.3/sql/sql_parse.cc:6483
          #17 0x562e91e28ba9 in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:3818
          #18 0x562e91e42cc7 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:8105
          #19 0x562e91e1d479 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1858
          #20 0x562e91e1a430 in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1403
          #21 0x562e9217fca6 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1402
          #22 0x562e9217f682 in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #23 0x562e9352aafb in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1862
          #24 0x7f2f28a5a4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
       
      Thread T5 created by T0 here:
          #0 0x7f2f28ca0f59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
          #1 0x562e9352af37 in spawn_thread_v1 /data/src/10.3/storage/perfschema/pfs.cc:1912
          #2 0x562e91b94830 in inline_mysql_thread_create /data/src/10.3/include/mysql/psi/mysql_thread.h:1268
          #3 0x562e91ba97a6 in create_thread_to_handle_connection(CONNECT*) /data/src/10.3/sql/mysqld.cc:6605
          #4 0x562e91ba9e9d in create_new_thread /data/src/10.3/sql/mysqld.cc:6675
          #5 0x562e91baaec4 in handle_connections_sockets() /data/src/10.3/sql/mysqld.cc:6950
          #6 0x562e91ba8c5e in mysqld_main(int, char**) /data/src/10.3/sql/mysqld.cc:6227
          #7 0x562e91b92f4f in main /data/src/10.3/sql/main.cc:25
          #8 0x7f2f26eda2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
       
      SUMMARY: AddressSanitizer: heap-use-after-free /data/src/10.3/storage/maria/ha_maria.cc:2446 in ha_maria::info(unsigned int)
      Shadow bytes around the buggy address:
        0x0c5280014c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5280014c10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5280014c20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5280014c30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c5280014c40: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
      =>0x0c5280014c50: fd fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd fd
        0x0c5280014c60: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5280014c70: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5280014c80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5280014c90: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c5280014ca0: 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
      ==25659==ABORTING
      

      Attachments

        Activity

          People

            monty Michael Widenius
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.