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

AddressSanitizer: use-after-poison upon update after an error with SIMULTANEOUS_ASSIGNMENT

    XMLWordPrintable

Details

    Description

      Note: The most of the stack trace closely resembles MDEV-16694, but given the top frames (in create_tmp_table and a very different test case, I'm not sure at all it's the same issue, so filing it separately. See also MDEV-22600 for a variety of test cases very similar to this one, with different failures.

      CREATE TABLE t1 (a INT);
      CREATE TABLE t2 (d DATE NOT NULL, g GEOMETRY);
      INSERT INTO t2 VALUES ('1981-09-12',NULL);
       
      SET SQL_MODE= 'SIMULTANEOUS_ASSIGNMENT,STRICT_ALL_TABLES';
       
      --error ER_BAD_NULL_ERROR
      UPDATE t2 SET d = NULL, g = 42;
      UPDATE t1 JOIN t2 SET d = NULL;
       
      # Cleanup
      DROP TABLE t1, t2;
      

      10.3 ASAN 7476e8c7

      ==10765==ERROR: AddressSanitizer: use-after-poison on address 0x619000095761 at pc 0x7f146348ff7f bp 0x7f14573be650 sp 0x7f14573bde00
      READ of size 3 at 0x619000095761 thread T5
          #0 0x7f146348ff7e  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x5cf7e)
          #1 0x55857c5dc1b7 in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.3/sql/sql_select.cc:17960
          #2 0x55857c746c9c in multi_update::initialize_tables(JOIN*) /data/src/10.3/sql/sql_update.cc:2237
          #3 0x55857c56d8e4 in JOIN::optimize_stage2() /data/src/10.3/sql/sql_select.cc:2013
          #4 0x55857c56d27c in JOIN::optimize_inner() /data/src/10.3/sql/sql_select.cc:1968
          #5 0x55857c568ad1 in JOIN::optimize() /data/src/10.3/sql/sql_select.cc:1488
          #6 0x55857c58374e 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:4292
          #7 0x55857c742c47 in mysql_multi_update(THD*, TABLE_LIST*, List<Item>*, List<Item>*, Item*, unsigned long long, enum_duplicates, bool, st_select_lex_unit*, st_select_lex*, multi_update**) /data/src/10.3/sql/sql_update.cc:1799
          #8 0x55857c4d192d in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:4369
          #9 0x55857c4e86dc in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:7818
          #10 0x55857c4c309d in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1856
          #11 0x55857c4bff49 in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1401
          #12 0x55857c836e33 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1403
          #13 0x55857c8367fa in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #14 0x55857dcab12b in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1869
          #15 0x7f146321d4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
          #16 0x7f1461351d0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)
       
      0x619000095761 is located 225 bytes inside of 1100-byte region [0x619000095680,0x619000095acc)
      allocated by thread T5 here:
          #0 0x7f14634f4d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x55857dddb548 in sf_malloc /data/src/10.3/mysys/safemalloc.c:118
          #2 0x55857ddad117 in my_malloc /data/src/10.3/mysys/my_malloc.c:101
          #3 0x55857dd8d63a in alloc_root /data/src/10.3/mysys/my_alloc.c:250
          #4 0x55857dd8ecbb in memdup_root /data/src/10.3/mysys/my_alloc.c:492
          #5 0x55857c7693e2 in TABLE_SHARE::init_from_binary_frm_image(THD*, bool, unsigned char const*, unsigned long) /data/src/10.3/sql/table.cc:1296
          #6 0x55857c764752 in open_table_def(THD*, TABLE_SHARE*, unsigned int) /data/src/10.3/sql/table.cc:680
          #7 0x55857c9ed320 in tdc_acquire_share(THD*, TABLE_LIST*, unsigned int, TABLE**) /data/src/10.3/sql/table_cache.cc:840
          #8 0x55857c372edc in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/src/10.3/sql/sql_base.cc:1839
          #9 0x55857c37bef3 in open_and_process_table /data/src/10.3/sql/sql_base.cc:3718
          #10 0x55857c37e17e in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /data/src/10.3/sql/sql_base.cc:4187
          #11 0x55857c38309b 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:5084
          #12 0x55857c2f4999 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/src/10.3/sql/sql_base.h:505
          #13 0x55857c434cf2 in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) /data/src/10.3/sql/sql_insert.cc:760
          #14 0x55857c4d1f69 in mysql_execute_command(THD*) /data/src/10.3/sql/sql_parse.cc:4454
          #15 0x55857c4e86dc in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.3/sql/sql_parse.cc:7818
          #16 0x55857c4c309d in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.3/sql/sql_parse.cc:1856
          #17 0x55857c4bff49 in do_command(THD*) /data/src/10.3/sql/sql_parse.cc:1401
          #18 0x55857c836e33 in do_handle_one_connection(CONNECT*) /data/src/10.3/sql/sql_connect.cc:1403
          #19 0x55857c8367fa in handle_one_connection /data/src/10.3/sql/sql_connect.cc:1308
          #20 0x55857dcab12b in pfs_spawn_thread /data/src/10.3/storage/perfschema/pfs.cc:1869
          #21 0x7f146321d4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
       
      Thread T5 created by T0 here:
          #0 0x7f1463463f59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
          #1 0x55857dcab567 in spawn_thread_v1 /data/src/10.3/storage/perfschema/pfs.cc:1919
          #2 0x55857c22c480 in inline_mysql_thread_create /data/src/10.3/include/mysql/psi/mysql_thread.h:1275
          #3 0x55857c24196f in create_thread_to_handle_connection(CONNECT*) /data/src/10.3/sql/mysqld.cc:6606
          #4 0x55857c242052 in create_new_thread /data/src/10.3/sql/mysqld.cc:6676
          #5 0x55857c24306a in handle_connections_sockets() /data/src/10.3/sql/mysqld.cc:6951
          #6 0x55857c240e3f in mysqld_main(int, char**) /data/src/10.3/sql/mysqld.cc:6228
          #7 0x55857c22ab9f in main /data/src/10.3/sql/main.cc:25
          #8 0x7f14612892e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
       
      SUMMARY: AddressSanitizer: use-after-poison (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x5cf7e) 
      Shadow bytes around the buggy address:
        0x0c328000aa90: 00 f7 00 00 00 04 f7 00 00 f7 f7 f7 f7 f7 f7 f7
        0x0c328000aaa0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c328000aab0: f7 f7 f7 f7 f7 f7 f7 f7 f7 04 fa fa fa fa fa fa
        0x0c328000aac0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c328000aad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c328000aae0: 00 f7 00 00 f7 01 f7 02 f7 00 00 f7[f7]01 f7 00
        0x0c328000aaf0: 00 00 00 00 00 00 00 00 00 00 00 00 f7 00 00 00
        0x0c328000ab00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000ab10: 00 00 00 00 00 00 00 f7 00 00 00 00 00 00 00 00
        0x0c328000ab20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000ab30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      ==10765==ABORTING
      

      10.5 03dcdad2 ASAN

      ==10975==ERROR: AddressSanitizer: use-after-poison on address 0x619000097a79 at pc 0x7fa08a868f7f bp 0x7fa07fdb1e90 sp 0x7fa07fdb1640
      READ of size 3 at 0x619000097a79 thread T5
          #0 0x7fa08a868f7e  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x5cf7e)
          #1 0x55c1b55111c5 in Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool) /data/src/10.5/sql/sql_select.cc:18799
          #2 0x55c1b5516602 in create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool) /data/src/10.5/sql/sql_select.cc:19172
          #3 0x55c1b56a0e0e in multi_update::initialize_tables(JOIN*) /data/src/10.5/sql/sql_update.cc:2362
          #4 0x55c1b549ceb7 in JOIN::optimize_stage2() /data/src/10.5/sql/sql_select.cc:2334
          #5 0x55c1b549c6d1 in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2286
          #6 0x55c1b5495f04 in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1606
          #7 0x55c1b54b3ba1 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.5/sql/sql_select.cc:4655
          #8 0x55c1b569ce64 in mysql_multi_update(THD*, TABLE_LIST*, List<Item>*, List<Item>*, Item*, unsigned long long, enum_duplicates, bool, st_select_lex_unit*, st_select_lex*, multi_update**) /data/src/10.5/sql/sql_update.cc:1929
          #9 0x55c1b53fddd2 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4477
          #10 0x55c1b5414267 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:7991
          #11 0x55c1b53eebdc in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1875
          #12 0x55c1b53eba5f in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1356
          #13 0x55c1b57a39a4 in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1411
          #14 0x55c1b57a3413 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1313
          #15 0x55c1b63878cc in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #16 0x7fa08a5f64a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
          #17 0x7fa08872ad0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)
       
      0x619000097a79 is located 249 bytes inside of 1124-byte region [0x619000097980,0x619000097de4)
      allocated by thread T5 here:
          #0 0x7fa08a8cdd28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
          #1 0x55c1b6e97d84 in sf_malloc /data/src/10.5/mysys/safemalloc.c:118
          #2 0x55c1b6e68f34 in my_malloc /data/src/10.5/mysys/my_malloc.c:88
          #3 0x55c1b6e49293 in alloc_root /data/src/10.5/mysys/my_alloc.c:243
          #4 0x55c1b6e4a7c2 in memdup_root /data/src/10.5/mysys/my_alloc.c:478
          #5 0x55c1b56c5de8 in TABLE_SHARE::init_from_binary_frm_image(THD*, bool, unsigned char const*, unsigned long, unsigned char const*, unsigned long) /data/src/10.5/sql/table.cc:1773
          #6 0x55c1b56beab7 in open_table_def(THD*, TABLE_SHARE*, unsigned int) /data/src/10.5/sql/table.cc:704
          #7 0x55c1b596d4a3 in tdc_acquire_share(THD*, TABLE_LIST*, unsigned int, TABLE**) /data/src/10.5/sql/table_cache.cc:831
          #8 0x55c1b52804c3 in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/src/10.5/sql/sql_base.cc:1836
          #9 0x55c1b5289737 in open_and_process_table /data/src/10.5/sql/sql_base.cc:3736
          #10 0x55c1b528bda5 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /data/src/10.5/sql/sql_base.cc:4210
          #11 0x55c1b5290b10 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /data/src/10.5/sql/sql_base.cc:5112
          #12 0x55c1b51faeeb in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/src/10.5/sql/sql_base.h:509
          #13 0x55c1b534708c in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /data/src/10.5/sql/sql_insert.cc:756
          #14 0x55c1b53fe591 in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4553
          #15 0x55c1b5414267 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:7991
          #16 0x55c1b53eebdc in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1875
          #17 0x55c1b53eba5f in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1356
          #18 0x55c1b57a39a4 in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1411
          #19 0x55c1b57a3413 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1313
          #20 0x55c1b63878cc in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #21 0x7fa08a5f64a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
       
      Thread T5 created by T0 here:
          #0 0x7fa08a83cf59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
          #1 0x55c1b638298e in my_thread_create /data/src/10.5/storage/perfschema/my_thread.h:34
          #2 0x55c1b6387cbb in pfs_spawn_thread_v1 /data/src/10.5/storage/perfschema/pfs.cc:2252
          #3 0x55c1b5135637 in inline_mysql_thread_create /data/src/10.5/include/mysql/psi/mysql_thread.h:1321
          #4 0x55c1b5148369 in create_thread_to_handle_connection(CONNECT*) /data/src/10.5/sql/mysqld.cc:5952
          #5 0x55c1b51488de in create_new_thread(CONNECT*) /data/src/10.5/sql/mysqld.cc:6011
          #6 0x55c1b5148a9b in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.5/sql/mysqld.cc:6076
          #7 0x55c1b514947e in handle_connections_sockets() /data/src/10.5/sql/mysqld.cc:6203
          #8 0x55c1b5147ccf in mysqld_main(int, char**) /data/src/10.5/sql/mysqld.cc:5621
          #9 0x55c1b5133e2f in main /data/src/10.5/sql/main.cc:25
          #10 0x7fa0886622e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
       
      SUMMARY: AddressSanitizer: use-after-poison (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x5cf7e) 
      Shadow bytes around the buggy address:
        0x0c328000aef0: 00 00 00 00 00 f7 00 00 00 04 f7 00 00 f7 f7 f7
        0x0c328000af00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c328000af10: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 04 fa fa fa
        0x0c328000af20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c328000af30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c328000af40: 00 00 00 00 f7 00 00 f7 01 f7 02 f7 00 00 f7[f7]
        0x0c328000af50: 01 f7 00 00 00 00 00 00 00 00 00 f7 00 00 00 00
        0x0c328000af60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000af70: 00 00 00 00 00 00 f7 00 00 00 00 00 00 00 00 00
        0x0c328000af80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000af90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      ==10975==ABORTING
      

      Both debug- and non-debug ASAN builds are affected.
      No obvious problem on a non-ASAN build.
      Reproducible on 10.3-10.5. The test case is not applicable to 10.2 due to SIMULTANEOUS_ASSIGNMENT.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              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.