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

Server crash or ASAN use-after-poison in Query_arena::free_items after executing a failing PS which reads from versioned table

    XMLWordPrintable

Details

    Description

      Note: I don't know why versioning is important here, but I couldn't get rid of it, neither by adding invisible columns nor virtual columns nor both, while with system versioning it happens regardless it's timestamp- or trx-based, explicit or implicit, InnoDB or MyISAM.

      CREATE TABLE t1 (a INT) WITH SYSTEM VERSIONING;
       
      PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE EXP(20010609211642053929)";
      --error ER_DATA_OUT_OF_RANGE
      EXECUTE stmt;
       
      # Cleanup
      --connection default
      DROP TABLE t1;
      

      10.3 ASAN 99fa7c6c2f9c

      =================================================================
      ==4078==ERROR: AddressSanitizer: use-after-poison on address 0x62b00002d010 at pc 0x555f6fb7e20c bp 0x7f670453f980 sp 0x7f670453f978
      READ of size 8 at 0x62b00002d010 thread T5
          #0 0x555f6fb7e20b in Query_arena::free_items() /data/src/10.3/sql/sql_class.cc:3782
          #1 0x555f6fcb6c1f in Prepared_statement::~Prepared_statement() /data/src/10.3/sql/sql_prepare.cc:3803
          #2 0x555f6fcb709f in Prepared_statement::~Prepared_statement() /data/src/10.3/sql/sql_prepare.cc:3812
          #3 0x555f6fb7f8b4 in delete_statement_as_hash_key /data/src/10.3/sql/sql_class.cc:3926
          #4 0x555f713eac1f in my_hash_free_elements /data/src/10.3/mysys/hash.c:129
          #5 0x555f713eaef9 in my_hash_reset /data/src/10.3/mysys/hash.c:171
          #6 0x555f6fb801b5 in Statement_map::reset() /data/src/10.3/sql/sql_class.cc:4058
          #7 0x555f6fb6c272 in THD::free_connection() /data/src/10.3/sql/sql_class.cc:1656
          #8 0x555f6f9cb036 in unlink_thd(THD*) /data/src/10.3/sql/mysqld.cc:2945
          #9 0x555f6f9cb98c in one_thread_per_connection_end(THD*, bool) /data/src/10.3/sql/mysqld.cc:3086
          #10 0x555f6ffb532e in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1421
          #11 0x555f6ffb4b21 in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #12 0x555f70abb749 in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1862
          #13 0x7f6710b03493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #14 0x7f670eee993e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x62b00002d010 is located 11792 bytes inside of 24716-byte region [0x62b00002a200,0x62b00003028c)
      allocated by thread T5 here:
          #0 0x7f6710d6d73f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x555f7147c862 in sf_malloc /data/src/10.3/mysys/safemalloc.c:118
          #2 0x555f7144b56a in my_malloc /data/src/10.3/mysys/my_malloc.c:101
          #3 0x555f71429d5b in init_alloc_root /data/src/10.3/mysys/my_alloc.c:81
          #4 0x555f6ff2ba59 in init_sql_alloc(st_mem_root*, char const*, unsigned int, unsigned int, unsigned long) /data/src/10.3/sql/thr_malloc.cc:65
          #5 0x555f6fcb6417 in Prepared_statement::Prepared_statement(THD*) /data/src/10.3/sql/sql_prepare.cc:3732
          #6 0x555f6fcb141a in mysql_sql_stmt_prepare(THD*) /data/src/10.3/sql/sql_prepare.cc:2777
          #7 0x555f6fc5a61b in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:3779
          #8 0x555f6fc74702 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:8001
          #9 0x555f6fc4efa8 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1846
          #10 0x555f6fc4c03f in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1391
          #11 0x555f6ffb510c in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1402
          #12 0x555f6ffb4b21 in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #13 0x555f70abb749 in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1862
          #14 0x7f6710b03493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
       
      Thread T5 created by T0 here:
          #0 0x7f6710d3cbba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x555f70abbd11 in spawn_thread_v1 /data/src/10.3/storage/perfschema/pfs.cc:1912
          #2 0x555f6f9c0c8e in inline_mysql_thread_create /data/src/10.3/include/mysql/psi/mysql_thread.h:1268
          #3 0x555f6f9d69b3 in create_thread_to_handle_connection(CONNECT*) /data/src/10.3/sql/mysqld.cc:6554
          #4 0x555f6f9d70b8 in create_new_thread /data/src/10.3/sql/mysqld.cc:6624
          #5 0x555f6f9d80c9 in handle_connections_sockets() /data/src/10.3/sql/mysqld.cc:6899
          #6 0x555f6f9d5e70 in mysqld_main(int, char**) /data/src/10.3/sql/mysqld.cc:6176
          #7 0x555f6f9bf02f in main /data/src/10.3/sql/main.cc:25
          #8 0x7f670ee212b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
       
      SUMMARY: AddressSanitizer: use-after-poison /data/src/10.3/sql/sql_class.cc:3782 Query_arena::free_items()
      Shadow bytes around the buggy address:
        0x0c567fffd9b0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffd9c0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffd9d0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffd9e0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffd9f0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      =>0x0c567fffda00: f7 f7[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffda10: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffda20: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffda30: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffda40: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c567fffda50: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      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
      ==4078==ABORTING
      

      10.3 debug 99fa7c6c2f9 via client (not MTR)

      #3  <signal handler called>
      #4  0x0000563bec8e777b in Item::delete_self (this=0x7fd67c0274b0) at /data/src/10.3/sql/item.h:1873
      #5  0x0000563bec8dd9e5 in Query_arena::free_items (this=0x7fd67c0221b8) at /data/src/10.3/sql/sql_class.cc:3785
      #6  0x0000563bec962821 in Prepared_statement::~Prepared_statement (this=0x7fd67c0221a0, __in_chrg=<optimized out>) at /data/src/10.3/sql/sql_prepare.cc:3803
      #7  0x0000563bec9629b0 in Prepared_statement::~Prepared_statement (this=0x7fd67c0221a0, __in_chrg=<optimized out>) at /data/src/10.3/sql/sql_prepare.cc:3812
      #8  0x0000563bec8de13b in delete_statement_as_hash_key (key=0x7fd67c0221a0) at /data/src/10.3/sql/sql_class.cc:3926
      #9  0x0000563bed3a21ab in my_hash_free_elements (hash=0x7fd67c002788) at /data/src/10.3/mysys/hash.c:129
      #10 0x0000563bed3a22c5 in my_hash_reset (hash=0x7fd67c002788) at /data/src/10.3/mysys/hash.c:171
      #11 0x0000563bec8de5b6 in Statement_map::reset (this=0x7fd67c002788) at /data/src/10.3/sql/sql_class.cc:4058
      #12 0x0000563bec8d698a in THD::free_connection (this=0x7fd67c000b00) at /data/src/10.3/sql/sql_class.cc:1656
      #13 0x0000563bec819adc in unlink_thd (thd=0x7fd67c000b00) at /data/src/10.3/sql/mysqld.cc:2945
      #14 0x0000563bec819fa5 in one_thread_per_connection_end (thd=0x7fd67c000b00, put_in_cache=true) at /data/src/10.3/sql/mysqld.cc:3086
      #15 0x0000563beca96976 in do_handle_one_connection (connect=0x563befe5bfa0) at /data/src/10.3/sql/sql_connect.cc:1421
      #16 0x0000563beca9661a in handle_one_connection (arg=0x563befe5bfa0) at /data/src/10.3/sql/sql_connect.cc:1308
      #17 0x00007fd6e3632494 in start_thread (arg=0x7fd6cc182700) at pthread_create.c:333
      #18 0x00007fd6e1a1893f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Attachments

        1. mdev16042_asan_LEX.test
          2 kB
          Elena Stepanova
        2. mdev16042_fix_prepare_information.test
          3 kB
          Elena Stepanova

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              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.