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

ASAN heap-use-after-free in myrocks::Rdb_transaction::on_commit upon CREATE OR REPLACE .. SELECT

    XMLWordPrintable

    Details

      Description

      INSTALL SONAME 'ha_rocksdb';
      CREATE OR REPLACE TABLE t (a INT) ENGINE=RocksDB AS SELECT 1 AS a;
      

      10.11 ba875e93

      ==1240302==ERROR: AddressSanitizer: heap-use-after-free on address 0x610000009be8 at pc 0x7f399cab1c3a bp 0x7f399e1a0a90 sp 0x7f399e1a0a88
      WRITE of size 8 at 0x610000009be8 thread T5
          #0 0x7f399cab1c39 in std::__atomic_base<long>::store(long, std::memory_order) /usr/include/c++/10/bits/atomic_base.h:404
          #1 0x7f399cab1c39 in std::__atomic_base<long>::operator=(long) /usr/include/c++/10/bits/atomic_base.h:297
          #2 0x7f399ca9803e in myrocks::Rdb_transaction::on_commit() (/mnt8t/bld/10.11-asan-nightly/lib/plugin/ha_rocksdb.so+0xcf403e)
          #3 0x7f399ca9ad9f in myrocks::Rdb_transaction_impl::commit_no_binlog() (/mnt8t/bld/10.11-asan-nightly/lib/plugin/ha_rocksdb.so+0xcf6d9f)
          #4 0x7f399ca93e51 in myrocks::Rdb_transaction::commit() (/mnt8t/bld/10.11-asan-nightly/lib/plugin/ha_rocksdb.so+0xcefe51)
          #5 0x7f399ca19c47 in rocksdb_commit /data/src/10.11/storage/rocksdb/ha_rocksdb.cc:4239
          #6 0x5639015f3ce7 in commit_one_phase_2 /data/src/10.11/sql/handler.cc:2068
          #7 0x5639015f389d in ha_commit_one_phase(THD*, bool) /data/src/10.11/sql/handler.cc:2021
          #8 0x5639015f1bf7 in ha_commit_trans(THD*, bool) /data/src/10.11/sql/handler.cc:1815
          #9 0x56390120a82d in trans_commit_stmt(THD*) /data/src/10.11/sql/transaction.cc:472
          #10 0x563900c8fb23 in select_create::send_eof() /data/src/10.11/sql/sql_insert.cc:5321
          #11 0x563900e45936 in JOIN::exec_inner() /data/src/10.11/sql/sql_select.cc:4690
          #12 0x563900e4427c in JOIN::exec() /data/src/10.11/sql/sql_select.cc:4591
          #13 0x563900e4869d 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.11/sql/sql_select.cc:5071
          #14 0x563900e18c7c in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.11/sql/sql_select.cc:582
          #15 0x56390103384d in Sql_cmd_create_table_like::execute(THD*) /data/src/10.11/sql/sql_table.cc:12759
          #16 0x563900d3fec3 in mysql_execute_command(THD*, bool) /data/src/10.11/sql/sql_parse.cc:5997
          #17 0x563900d4d2bf in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.11/sql/sql_parse.cc:8037
          #18 0x563900d23921 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/10.11/sql/sql_parse.cc:1894
          #19 0x563900d206f9 in do_command(THD*, bool) /data/src/10.11/sql/sql_parse.cc:1407
          #20 0x5639011c7291 in do_handle_one_connection(CONNECT*, bool) /data/src/10.11/sql/sql_connect.cc:1416
          #21 0x5639011c6c27 in handle_one_connection /data/src/10.11/sql/sql_connect.cc:1318
          #22 0x563901da0f93 in pfs_spawn_thread /data/src/10.11/storage/perfschema/pfs.cc:2201
          #23 0x7f39a7985ea6 in start_thread nptl/pthread_create.c:477
          #24 0x7f39a7574aee in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xfcaee)
       
      0x610000009be8 is located 168 bytes inside of 192-byte region [0x610000009b40,0x610000009c00)
      freed by thread T5 here:
          #0 0x7f39a7e8f017 in operator delete(void*) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:160
          #1 0x7f399cba55ea in myrocks::Rdb_ddl_manager::remove(myrocks::Rdb_tbl_def*, rocksdb::WriteBatch*, bool) /data/src/10.11/storage/rocksdb/rdb_datadic.cc:4423
          #2 0x7f399cba5bfb in myrocks::Rdb_ddl_manager::rename(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::WriteBatch*) /data/src/10.11/storage/rocksdb/rdb_datadic.cc:4465
          #3 0x7f399ca597f0 in myrocks::ha_rocksdb::rename_table(char const*, char const*) /data/src/10.11/storage/rocksdb/ha_rocksdb.cc:11908
          #4 0x563901611d1a in handler::ha_rename_table(char const*, char const*) /data/src/10.11/sql/handler.cc:5347
          #5 0x563900ffdf93 in mysql_rename_table(handlerton*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, st_mysql_const_unsigned_lex_string*, unsigned int) /data/src/10.11/sql/sql_table.cc:5536
          #6 0x563900dea5bf in rename_table_and_triggers(THD*, rename_param*, st_ddl_log_state*, Table_name*, st_mysql_const_lex_string const*, bool, bool*) /data/src/10.11/sql/sql_rename.cc:384
          #7 0x563900ff6fa5 in HA_CREATE_INFO::finalize_atomic_replace(THD*, TABLE_LIST*) /data/src/10.11/sql/sql_table.cc:4481
          #8 0x563900c8f94b in select_create::send_eof() /data/src/10.11/sql/sql_insert.cc:5307
          #9 0x563900e45936 in JOIN::exec_inner() /data/src/10.11/sql/sql_select.cc:4690
          #10 0x563900e4427c in JOIN::exec() /data/src/10.11/sql/sql_select.cc:4591
          #11 0x563900e4869d 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.11/sql/sql_select.cc:5071
          #12 0x563900e18c7c in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.11/sql/sql_select.cc:582
          #13 0x56390103384d in Sql_cmd_create_table_like::execute(THD*) /data/src/10.11/sql/sql_table.cc:12759
          #14 0x563900d3fec3 in mysql_execute_command(THD*, bool) /data/src/10.11/sql/sql_parse.cc:5997
          #15 0x563900d4d2bf in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.11/sql/sql_parse.cc:8037
          #16 0x563900d23921 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/10.11/sql/sql_parse.cc:1894
          #17 0x563900d206f9 in do_command(THD*, bool) /data/src/10.11/sql/sql_parse.cc:1407
          #18 0x5639011c7291 in do_handle_one_connection(CONNECT*, bool) /data/src/10.11/sql/sql_connect.cc:1416
          #19 0x5639011c6c27 in handle_one_connection /data/src/10.11/sql/sql_connect.cc:1318
          #20 0x563901da0f93 in pfs_spawn_thread /data/src/10.11/storage/perfschema/pfs.cc:2201
          #21 0x7f39a7985ea6 in start_thread nptl/pthread_create.c:477
       
      previously allocated by thread T5 here:
          #0 0x7f39a7e8e647 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
          #1 0x7f399ca36dd6 in myrocks::ha_rocksdb::create_table(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, TABLE const*, unsigned long long) /data/src/10.11/storage/rocksdb/ha_rocksdb.cc:7748
          #2 0x7f399ca38172 in myrocks::ha_rocksdb::create(char const*, TABLE*, HA_CREATE_INFO*) /data/src/10.11/storage/rocksdb/ha_rocksdb.cc:7914
          #3 0x563901612851 in handler::ha_create(char const*, TABLE*, HA_CREATE_INFO*) /data/src/10.11/sql/handler.cc:5468
          #4 0x563901616e87 in ha_create_table(THD*, char const*, char const*, char const*, HA_CREATE_INFO*, st_mysql_const_unsigned_lex_string*, bool) /data/src/10.11/sql/handler.cc:5937
          #5 0x563900ff9d94 in create_table_impl /data/src/10.11/sql/sql_table.cc:4968
          #6 0x563900ffa984 in mysql_create_table_no_lock(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, Alter_info*, bool*, int, TABLE_LIST*, st_mysql_const_unsigned_lex_string*) /data/src/10.11/sql/sql_table.cc:5095
          #7 0x563900c897e7 in select_create::create_table_from_items(THD*, List<Item>*, st_mysql_lock**) /data/src/10.11/sql/sql_insert.cc:4690
          #8 0x563900c8ba5b in select_create::prepare(List<Item>&, st_select_lex_unit*) /data/src/10.11/sql/sql_insert.cc:4945
          #9 0x563900e25568 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.11/sql/sql_select.cc:1738
          #10 0x563900e4841d 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.11/sql/sql_select.cc:5046
          #11 0x563900e18c7c in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.11/sql/sql_select.cc:582
          #12 0x56390103384d in Sql_cmd_create_table_like::execute(THD*) /data/src/10.11/sql/sql_table.cc:12759
          #13 0x563900d3fec3 in mysql_execute_command(THD*, bool) /data/src/10.11/sql/sql_parse.cc:5997
          #14 0x563900d4d2bf in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.11/sql/sql_parse.cc:8037
          #15 0x563900d23921 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/10.11/sql/sql_parse.cc:1894
          #16 0x563900d206f9 in do_command(THD*, bool) /data/src/10.11/sql/sql_parse.cc:1407
          #17 0x5639011c7291 in do_handle_one_connection(CONNECT*, bool) /data/src/10.11/sql/sql_connect.cc:1416
          #18 0x5639011c6c27 in handle_one_connection /data/src/10.11/sql/sql_connect.cc:1318
          #19 0x563901da0f93 in pfs_spawn_thread /data/src/10.11/storage/perfschema/pfs.cc:2201
          #20 0x7f39a7985ea6 in start_thread nptl/pthread_create.c:477
       
      Thread T5 created by T0 here:
          #0 0x7f39a7e382a2 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:214
          #1 0x563901d9ccfc in my_thread_create /data/src/10.11/storage/perfschema/my_thread.h:52
          #2 0x563901da1382 in pfs_spawn_thread_v1 /data/src/10.11/storage/perfschema/pfs.cc:2252
          #3 0x563900971599 in inline_mysql_thread_create /data/src/10.11/include/mysql/psi/mysql_thread.h:1139
          #4 0x563900988ac7 in create_thread_to_handle_connection(CONNECT*) /data/src/10.11/sql/mysqld.cc:6029
          #5 0x56390098910d in create_new_thread(CONNECT*) /data/src/10.11/sql/mysqld.cc:6088
          #6 0x56390098944f in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.11/sql/mysqld.cc:6150
          #7 0x563900989dc3 in handle_connections_sockets() /data/src/10.11/sql/mysqld.cc:6274
          #8 0x563900988336 in mysqld_main(int, char**) /data/src/10.11/sql/mysqld.cc:5924
          #9 0x5639009708e4 in main /data/src/10.11/sql/main.cc:34
          #10 0x7f39a749bd09 in __libc_start_main ../csu/libc-start.c:308
       
      SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/10/bits/atomic_base.h:404 in std::__atomic_base<long>::store(long, std::memory_order)
      Shadow bytes around the buggy address:
        0x0c207fff9320: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
        0x0c207fff9330: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c207fff9340: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
        0x0c207fff9350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c207fff9360: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
      =>0x0c207fff9370: fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd fd
        0x0c207fff9380: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
        0x0c207fff9390: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c207fff93a0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
        0x0c207fff93b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c207fff93c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      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
      ==1240302==ABORTING
      

      The failure appeared in 10.11 with

      commit 93c8252f02faa8ad8dc5f005e52f1990c29d4a0d
      Author: Aleksey Midenkov
      Date:   Wed Aug 31 11:55:04 2022 +0300
       
          MDEV-25292 Atomic CREATE OR REPLACE TABLE
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.