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

ASAN use-after-poison in Item_change_list::rollback_item_tree_changes on 1st execution of PS

    XMLWordPrintable

Details

    Description

      CREATE TABLE t1 (a INT) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (1),(2);
       
      CREATE TABLE t2 (b INT) ENGINE=MyISAM;
      INSERT INTO t2 VALUES (3);
       
      PREPARE stmt FROM "SELECT * FROM t1 JOIN t2 HAVING NOT (t1.a IS NULL AND t2.b <> 1)";
      EXECUTE stmt;
       
      # Cleanup
      DEALLOCATE PREPARE stmt;
      DROP TABLE t1, t2;
      

      10.4 bb970dda

      ==3420==ERROR: AddressSanitizer: use-after-poison on address 0x62b0000624b8 at pc 0x5591343eb19f bp 0x7f8c025e35e0 sp 0x7f8c025e35d8
      WRITE of size 8 at 0x62b0000624b8 thread T5
          #0 0x5591343eb19e in Item_change_list::rollback_item_tree_changes() /data/src/10.4/sql/sql_class.cc:2879
          #1 0x55913454c108 in Prepared_statement::cleanup_stmt() /data/src/10.4/sql/sql_prepare.cc:3866
          #2 0x559134552933 in Prepared_statement::execute(String*, bool) /data/src/10.4/sql/sql_prepare.cc:4763
          #3 0x55913454e3d4 in Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*) /data/src/10.4/sql/sql_prepare.cc:4221
          #4 0x559134548e07 in mysql_sql_stmt_execute(THD*) /data/src/10.4/sql/sql_prepare.cc:3338
          #5 0x5591344ed165 in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:3857
          #6 0x559134508e8a in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.4/sql/sql_parse.cc:8157
          #7 0x5591344e1093 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.4/sql/sql_parse.cc:1829
          #8 0x5591344dde94 in do_command(THD*) /data/src/10.4/sql/sql_parse.cc:1358
          #9 0x559134871793 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1399
          #10 0x55913487118c in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1302
          #11 0x55913543b82c in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #12 0x7f8c0d964493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #13 0x7f8c0bd4a93e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x62b0000624b8 is located 696 bytes inside of 24716-byte region [0x62b000062200,0x62b00006828c)
      allocated by thread T5 here:
          #0 0x7f8c0dbce73f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x559135deb2c7 in sf_malloc /data/src/10.4/mysys/safemalloc.c:118
          #2 0x559135dbbbc2 in my_malloc /data/src/10.4/mysys/my_malloc.c:101
          #3 0x559135d9a9a4 in reset_root_defaults /data/src/10.4/mysys/my_alloc.c:151
          #4 0x5591343e017b in THD::init_for_queries() /data/src/10.4/sql/sql_class.cc:1370
          #5 0x559134870b40 in prepare_new_connection_state(THD*) /data/src/10.4/sql/sql_connect.cc:1233
          #6 0x5591348711d2 in thd_prepare_connection(THD*) /data/src/10.4/sql/sql_connect.cc:1317
          #7 0x559134871760 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1387
          #8 0x55913487118c in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1302
          #9 0x55913543b82c in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #10 0x7f8c0d964493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
       
      Thread T5 created by T0 here:
          #0 0x7f8c0db9dbba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x55913543bdf4 in spawn_thread_v1 /data/src/10.4/storage/perfschema/pfs.cc:1912
          #2 0x55913422bf16 in inline_mysql_thread_create /data/src/10.4/include/mysql/psi/mysql_thread.h:1268
          #3 0x559134241740 in create_thread_to_handle_connection(CONNECT*) /data/src/10.4/sql/mysqld.cc:6194
          #4 0x559134241e45 in create_new_thread(CONNECT*) /data/src/10.4/sql/mysqld.cc:6264
          #5 0x5591342421d5 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.4/sql/mysqld.cc:6362
          #6 0x559134242e21 in handle_connections_sockets() /data/src/10.4/sql/mysqld.cc:6520
          #7 0x559134240f7b in mysqld_main(int, char**) /data/src/10.4/sql/mysqld.cc:5852
          #8 0x559134229d9f in main /data/src/10.4/sql/main.cc:25
          #9 0x7f8c0bc822b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
       
      SUMMARY: AddressSanitizer: use-after-poison /data/src/10.4/sql/sql_class.cc:2879 Item_change_list::rollback_item_tree_changes()
      Shadow bytes around the buggy address:
        0x0c5680004440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00
        0x0c5680004460: 05 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004470: 00 00 00 00 00 07 00 00 00 00 00 00 00 00 00 00
        0x0c5680004480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c5680004490: 00 00 00 00 00 00 f7[f7]00 00 00 00 00 00 00 00
        0x0c56800044a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c56800044b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c56800044c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c56800044d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c56800044e0: 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
      ==3420==ABORTING
      

      Attachments

        Issue Links

          Activity

            People

              alice Alice Sherepa
              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.