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

ASAN use-after-poison in Field::pack_int / THD::binlog_update_row

    XMLWordPrintable

    Details

      Description

      --source include/have_log_bin.inc
       
      CREATE TABLE t1 (pk INT, a VARCHAR(3), b VARCHAR(1) AS (a) VIRTUAL, PRIMARY KEY (pk));
      INSERT IGNORE INTO t1 (pk, a) VALUES (1,'foo'),(2,'bar');
      --error ER_DATA_TOO_LONG
      REPLACE INTO t1 (pk) VALUES (2);
      UPDATE IGNORE t1 SET a = NULL;
       
      # Cleanup
      DROP TABLE t1;
      

      10.2 6ede84f4

      ==3986667==ERROR: AddressSanitizer: use-after-poison on address 0x619000098e41 at pc 0x7f42c99e6480 bp 0x7f42be71ba90 sp 0x7f42be71b238
      READ of size 4 at 0x619000098e41 thread T6
          #0 0x7f42c99e647f  (/lib/x86_64-linux-gnu/libasan.so.5+0x9b47f)
          #1 0x5591047c8144 in Field::pack_int(unsigned char*, unsigned char const*, unsigned long) /data/src/10.2/sql/field.h:1608
          #2 0x5591047c824e in Field::pack_int32(unsigned char*, unsigned char const*) /data/src/10.2/sql/field.h:1630
          #3 0x5591047ca35d in Field_long::pack(unsigned char*, unsigned char const*, unsigned int) /data/src/10.2/sql/field.h:2176
          #4 0x559104b179be in pack_row(TABLE*, st_bitmap const*, unsigned char*, unsigned char const*) /data/src/10.2/sql/rpl_record.cc:106
          #5 0x559104111e29 in THD::binlog_update_row(TABLE*, bool, unsigned char const*, unsigned char const*) /data/src/10.2/sql/sql_class.cc:6486
          #6 0x55910481e172 in Update_rows_log_event::binlog_row_logging_function(THD*, TABLE*, bool, unsigned char const*, unsigned char const*) /data/src/10.2/sql/log_event.h:4808
          #7 0x559104817300 in binlog_log_row_internal /data/src/10.2/sql/handler.cc:5962
          #8 0x5591048177f8 in binlog_log_row /data/src/10.2/sql/handler.cc:5998
          #9 0x559104819504 in handler::ha_update_row(unsigned char const*, unsigned char*) /data/src/10.2/sql/handler.cc:6157
          #10 0x55910443a325 in mysql_update(THD*, TABLE_LIST*, List<Item>&, List<Item>&, Item*, unsigned int, st_order*, unsigned long long, enum_duplicates, bool, unsigned long long*, unsigned long long*) /data/src/10.2/sql/sql_update.cc:819
          #11 0x5591041b766d in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:4033
          #12 0x5591041d10ef in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7763
          #13 0x5591041aa134 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1827
          #14 0x5591041a6ef3 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1381
          #15 0x55910452f774 in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #16 0x55910452f037 in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #17 0x5591058cb4b7 in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1869
          #18 0x7f42c94f1608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
          #19 0x7f42c90cb292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
       
      0x619000098e41 is located 193 bytes inside of 1100-byte region [0x619000098d80,0x6190000991cc)
      allocated by thread T6 here:
          #0 0x7f42c9a58bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
          #1 0x5591059e8012 in sf_malloc /data/src/10.2/mysys/safemalloc.c:118
          #2 0x5591059b3f77 in my_malloc /data/src/10.2/mysys/my_malloc.c:101
          #3 0x5591059915e9 in alloc_root /data/src/10.2/mysys/my_alloc.c:243
          #4 0x559105992f82 in strmake_root /data/src/10.2/mysys/my_alloc.c:451
          #5 0x559104475ca7 in open_table_from_share(THD*, TABLE_SHARE*, char const*, unsigned int, unsigned int, unsigned int, TABLE*, bool) /data/src/10.2/sql/table.cc:3103
          #6 0x55910408bcfd in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/src/10.2/sql/sql_base.cc:1934
          #7 0x559104093c82 in open_and_process_table /data/src/10.2/sql/sql_base.cc:3614
          #8 0x55910409605c in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /data/src/10.2/sql/sql_base.cc:4081
          #9 0x559104099be2 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /data/src/10.2/sql/sql_base.cc:4880
          #10 0x559104010db1 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /data/src/10.2/sql/sql_base.h:507
          #11 0x55910414fabd in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) /data/src/10.2/sql/sql_insert.cc:758
          #12 0x5591041b8495 in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:4194
          #13 0x5591041d10ef in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7763
          #14 0x5591041aa134 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1827
          #15 0x5591041a6ef3 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1381
          #16 0x55910452f774 in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #17 0x55910452f037 in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #18 0x5591058cb4b7 in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1869
          #19 0x7f42c94f1608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
       
      Thread T6 created by T0 here:
          #0 0x7f42c9985805 in pthread_create (/lib/x86_64-linux-gnu/libasan.so.5+0x3a805)
          #1 0x5591058cb8a8 in spawn_thread_v1 /data/src/10.2/storage/perfschema/pfs.cc:1919
          #2 0x559103f4c083 in inline_mysql_thread_create /data/src/10.2/include/mysql/psi/mysql_thread.h:1246
          #3 0x559103f63c54 in create_thread_to_handle_connection(CONNECT*) /data/src/10.2/sql/mysqld.cc:6573
          #4 0x559103f643ef in create_new_thread /data/src/10.2/sql/mysqld.cc:6643
          #5 0x559103f65581 in handle_connections_sockets() /data/src/10.2/sql/mysqld.cc:6901
          #6 0x559103f62fa5 in mysqld_main(int, char**) /data/src/10.2/sql/mysqld.cc:6192
          #7 0x559103f4a93c in main /data/src/10.2/sql/main.cc:25
          #8 0x7f42c8fd00b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
       
      SUMMARY: AddressSanitizer: use-after-poison (/lib/x86_64-linux-gnu/libasan.so.5+0x9b47f) 
      Shadow bytes around the buggy address:
        0x0c328000b170: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c328000b180: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c328000b190: f7 f7 f7 f7 f7 f7 f7 f7 f7 04 fa fa fa fa fa fa
        0x0c328000b1a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c328000b1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x0c328000b1c0: 00 f7 03 f7 00 03 00 03[f7]00 00 00 00 f7 00 00
        0x0c328000b1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000b1e0: 00 00 00 00 00 00 00 f7 00 00 00 00 00 00 00 00
        0x0c328000b1f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000b200: 00 00 00 f7 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c328000b210: 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
        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
      ==3986667==ABORTING
      

      Reproducible on 10.2-10.6 with at least MyISAM and InnoDB.
      No obvious immediate problem on a non-ASAN build.
      Can be related (or not) to a number of issues with virtual columns, e.g. MDEV-24665, and/or to MDEV-24646; but there are too many differences to be sure.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              nikitamalyavin Nikita Malyavin
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration