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

Server crash or ASAN use-after-poison in Item_equal_iterator / st_select_lex::pushdown_from_having_into_where upon query with impossible WHERE condition

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.4(EOL)
    • 10.4.4
    • Optimizer
    • None

    Description

      CREATE TABLE t1 (a INT, b INT);
      # Optional, it fails either way
      INSERT INTO t1 VALUES (1,1),(2,2);
       
      SELECT a FROM t1 WHERE b = 1 AND b = 2 GROUP BY a HAVING a <= 3;
       
      # Cleanup
      DROP TABLE t1;
      

      10.4 c0f47a4a ASAN

      ==15442==ERROR: AddressSanitizer: use-after-poison on address 0x62b0000651a8 at pc 0x55ce8d469a1d bp 0x7fc0f0b70140 sp 0x7fc0f0b70138
      READ of size 8 at 0x62b0000651a8 thread T5
          #0 0x55ce8d469a1c in base_list_iterator::next_fast() /data/src/10.4/sql/sql_list.h:433
          #1 0x55ce8d6dce50 in List_iterator_fast<Item_equal>::operator++(int) /data/src/10.4/sql/sql_list.h:554
          #2 0x55ce8d6ca09e in st_select_lex::collect_fields_equal_to_grouping(THD*) /data/src/10.4/sql/sql_lex.cc:9887
          #3 0x55ce8d6cabf4 in st_select_lex::pushdown_from_having_into_where(THD*, Item*) /data/src/10.4/sql/sql_lex.cc:10089
          #4 0x55ce8d7a723d in JOIN::optimize_inner() /data/src/10.4/sql/sql_select.cc:1893
          #5 0x55ce8d7a3680 in JOIN::optimize() /data/src/10.4/sql/sql_select.cc:1508
          #6 0x55ce8d7c0d0b 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.4/sql/sql_select.cc:4518
          #7 0x55ce8d798520 in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.4/sql/sql_select.cc:423
          #8 0x55ce8d71922a in execute_sqlcom_select /data/src/10.4/sql/sql_parse.cc:6588
          #9 0x55ce8d705db3 in mysql_execute_command(THD*) /data/src/10.4/sql/sql_parse.cc:3825
          #10 0x55ce8d721b1c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.4/sql/sql_parse.cc:8141
          #11 0x55ce8d6f9e17 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.4/sql/sql_parse.cc:1820
          #12 0x55ce8d6f6d0a in do_command(THD*) /data/src/10.4/sql/sql_parse.cc:1358
          #13 0x55ce8da7fb67 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1399
          #14 0x55ce8da7f560 in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1302
          #15 0x55ce8e643770 in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #16 0x7fc0fbef0493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
          #17 0x7fc0fa2d693e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe893e)
       
      0x62b0000651a8 is located 12200 bytes inside of 24716-byte region [0x62b000062200,0x62b00006828c)
      allocated by thread T5 here:
          #0 0x7fc0fc15a73f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
          #1 0x55ce8eff1840 in sf_malloc /data/src/10.4/mysys/safemalloc.c:118
          #2 0x55ce8efc220c in my_malloc /data/src/10.4/mysys/my_malloc.c:101
          #3 0x55ce8efa1451 in reset_root_defaults /data/src/10.4/mysys/my_alloc.c:151
          #4 0x55ce8d5f976b in THD::init_for_queries() /data/src/10.4/sql/sql_class.cc:1369
          #5 0x55ce8da7ef14 in prepare_new_connection_state(THD*) /data/src/10.4/sql/sql_connect.cc:1233
          #6 0x55ce8da7f5a6 in thd_prepare_connection(THD*) /data/src/10.4/sql/sql_connect.cc:1317
          #7 0x55ce8da7fb34 in do_handle_one_connection(CONNECT*) /data/src/10.4/sql/sql_connect.cc:1387
          #8 0x55ce8da7f560 in handle_one_connection /data/src/10.4/sql/sql_connect.cc:1302
          #9 0x55ce8e643770 in pfs_spawn_thread /data/src/10.4/storage/perfschema/pfs.cc:1862
          #10 0x7fc0fbef0493 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x7493)
       
      Thread T5 created by T0 here:
          #0 0x7fc0fc129bba in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x23bba)
          #1 0x55ce8e643d38 in spawn_thread_v1 /data/src/10.4/storage/perfschema/pfs.cc:1912
          #2 0x55ce8d447bb6 in inline_mysql_thread_create /data/src/10.4/include/mysql/psi/mysql_thread.h:1268
          #3 0x55ce8d45d3e0 in create_thread_to_handle_connection(CONNECT*) /data/src/10.4/sql/mysqld.cc:6192
          #4 0x55ce8d45dae5 in create_new_thread(CONNECT*) /data/src/10.4/sql/mysqld.cc:6262
          #5 0x55ce8d45de75 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.4/sql/mysqld.cc:6360
          #6 0x55ce8d45eac1 in handle_connections_sockets() /data/src/10.4/sql/mysqld.cc:6518
          #7 0x55ce8d45cc1b in mysqld_main(int, char**) /data/src/10.4/sql/mysqld.cc:5850
          #8 0x55ce8d445a3f in main /data/src/10.4/sql/main.cc:25
          #9 0x7fc0fa20e2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
       
      SUMMARY: AddressSanitizer: use-after-poison /data/src/10.4/sql/sql_list.h:433 base_list_iterator::next_fast()
      Shadow bytes around the buggy address:
        0x0c56800049e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c56800049f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c5680004a30: 00 00 00 00 f7[f7]00 00 00 00 00 00 00 00 f7 f7
        0x0c5680004a40: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004a50: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004a60: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004a70: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c5680004a80: 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
      ==15442==ABORTING
      

      10.4 c0f47a4a debug

      #1  0x000056283151b442 in my_write_core (sig=11) at /data/src/10.4/mysys/stacktrace.c:481
      #2  0x0000562830d4a946 in handle_fatal_signal (sig=11) at /data/src/10.4/sql/signal_handler.cc:305
      #3  <signal handler called>
      #4  0x00005628309fbd5a in Item_equal_iterator<List_iterator_fast, Item>::Item_equal_iterator (this=0x7fec3c375e10, item_eq=...) at /data/src/10.4/sql/item_cmpfunc.h:3273
      #5  0x00005628309f7067 in Item_equal_fields_iterator::Item_equal_fields_iterator (this=0x7fec3c375e10, item_eq=...) at /data/src/10.4/sql/item_cmpfunc.h:3306
      #6  0x00005628309f3f90 in st_select_lex::collect_fields_equal_to_grouping (this=0x7fec20015418, thd=0x7fec20000b00) at /data/src/10.4/sql/sql_lex.cc:9889
      #7  0x00005628309f45a7 in st_select_lex::pushdown_from_having_into_where (this=0x7fec20015418, thd=0x7fec20000b00, having=0x7fec20016c48) at /data/src/10.4/sql/sql_lex.cc:10089
      #8  0x0000562830a585dc in JOIN::optimize_inner (this=0x7fec200176f8) at /data/src/10.4/sql/sql_select.cc:1893
      #9  0x0000562830a56fd8 in JOIN::optimize (this=0x7fec200176f8) at /data/src/10.4/sql/sql_select.cc:1508
      #10 0x0000562830a61e86 in mysql_select (thd=0x7fec20000b00, tables=0x7fec200159d8, wild_num=0, fields=..., conds=0x7fec20016800, og_num=1, order=0x0, group=0x7fec20016a50, having=0x7fec20016c48, proc_param=0x0, select_options=2147748608, result=0x7fec200176d0, unit=0x7fec20004a10, select_lex=0x7fec20015418) at /data/src/10.4/sql/sql_select.cc:4518
      #11 0x0000562830a52956 in handle_select (thd=0x7fec20000b00, lex=0x7fec20004948, result=0x7fec200176d0, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:423
      #12 0x0000562830a1be5d in execute_sqlcom_select (thd=0x7fec20000b00, all_tables=0x7fec200159d8) at /data/src/10.4/sql/sql_parse.cc:6588
      #13 0x0000562830a11104 in mysql_execute_command (thd=0x7fec20000b00) at /data/src/10.4/sql/sql_parse.cc:3825
      #14 0x0000562830a1fdac in mysql_parse (thd=0x7fec20000b00, rawbuf=0x7fec20015338 "SELECT a FROM t1 WHERE b = 1 AND b = 2 GROUP BY a HAVING a <= 3", length=63, parser_state=0x7fec3c3771f0, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8141
      #15 0x0000562830a0b4ea in dispatch_command (command=COM_QUERY, thd=0x7fec20000b00, packet=0x7fec20138e01 "SELECT a FROM t1 WHERE b = 1 AND b = 2 GROUP BY a HAVING a <= 3", packet_length=63, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1820
      #16 0x0000562830a09d5a in do_command (thd=0x7fec20000b00) at /data/src/10.4/sql/sql_parse.cc:1358
      #17 0x0000562830b7f713 in do_handle_one_connection (connect=0x5628348ac7f0) at /data/src/10.4/sql/sql_connect.cc:1399
      #18 0x0000562830b7f484 in handle_one_connection (arg=0x5628348ac7f0) at /data/src/10.4/sql/sql_connect.cc:1302
      #19 0x0000562831073911 in pfs_spawn_thread (arg=0x56283499eaa0) at /data/src/10.4/storage/perfschema/pfs.cc:1862
      #20 0x00007fec42f2e494 in start_thread (arg=0x7fec3c378700) at pthread_create.c:333
      #21 0x00007fec4131493f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Reproducible with at least InnoDB and MyISAM.
      Not reproducible on 10.3.

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.