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

ASAN errors in err_conv / field_unpack upon multi-UPDATE causing ER_DUP_ENTRY

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.7(EOL), 10.8(EOL), 10.9(EOL)
    • 10.5, 10.6
    • Server
    • None

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (
        pk INT,
        a CHAR(3),
        b TEXT,
        c TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        d INT,
        PRIMARY KEY (pk),
        UNIQUE (b(3), c)
      ) ENGINE=InnoDB;
       
      INSERT INTO t1 VALUES
        (1, 'foo', 'qux', '2025-08-15', 11),
        (2, 'bar', 'qux', '2037-01-11', 12);
       
      CREATE TABLE t2 (f CHAR(3)) ENGINE=InnoDB;
      INSERT INTO t2 VALUES ('abc'),('def');
       
      --error ER_DUP_ENTRY
      UPDATE t1 LEFT JOIN t2 ON (t1.a = t2.f) SET t1.d = 1;
       
      # Cleanup
      DROP TABLE t1, t2;
      

      10.2 d06205ba ASAN

      ==23215==ERROR: AddressSanitizer: heap-use-after-free on address 0x62900014a288 at pc 0x5631fbc40edc bp 0x7f28e11ab5c0 sp 0x7f28e11ab5b0
      READ of size 1 at 0x62900014a288 thread T27
          #0 0x5631fbc40edb in my_convert /data/src/10.2/strings/ctype.c:1122
          #1 0x5631fa13aa03 in copy_and_convert(char*, unsigned int, charset_info_st const*, char const*, unsigned int, charset_info_st const*, unsigned int*) /data/src/10.2/sql/sql_string.h:44
          #2 0x5631fa2e34ac in err_conv(char*, unsigned int, char const*, unsigned int, charset_info_st const*) /data/src/10.2/sql/sql_error.cc:947
          #3 0x5631fa15ab95 in ErrConvString::ptr() const /data/src/10.2/sql/sql_error.h:577
          #4 0x5631fac13887 in field_unpack(String*, Field*, unsigned char const*, unsigned int, bool) /data/src/10.2/sql/key.cc:397
          #5 0x5631fac13f07 in key_unpack(String*, TABLE*, st_key*) /data/src/10.2/sql/key.cc:440
          #6 0x5631fa9abd95 in print_keydup_error(TABLE*, st_key*, char const*, unsigned long) /data/src/10.2/sql/handler.cc:3481
          #7 0x5631fa9abfe5 in print_keydup_error(TABLE*, st_key*, unsigned long) /data/src/10.2/sql/handler.cc:3501
          #8 0x5631fa9ac531 in handler::print_error(int, unsigned long) /data/src/10.2/sql/handler.cc:3578
          #9 0x5631fa5e9dd9 in multi_update::send_data(List<Item>&) /data/src/10.2/sql/sql_update.cc:2225
          #10 0x5631fa485d04 in end_send /data/src/10.2/sql/sql_select.cc:20046
          #11 0x5631fa47f3a5 in evaluate_null_complemented_join_record /data/src/10.2/sql/sql_select.cc:19217
          #12 0x5631fa47d8e4 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18918
          #13 0x5631fa47e82a in evaluate_join_record /data/src/10.2/sql/sql_select.cc:19094
          #14 0x5631fa47d82d in sub_select(JOIN*, st_join_table*, bool) /data/src/10.2/sql/sql_select.cc:18913
          #15 0x5631fa47b285 in do_select /data/src/10.2/sql/sql_select.cc:18418
          #16 0x5631fa4150da in JOIN::exec_inner() /data/src/10.2/sql/sql_select.cc:3651
          #17 0x5631fa412bf1 in JOIN::exec() /data/src/10.2/sql/sql_select.cc:3446
          #18 0x5631fa416474 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.2/sql/sql_select.cc:3849
          #19 0x5631fa5e3ea0 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.2/sql/sql_update.cc:1643
          #20 0x5631fa35a211 in mysql_execute_command(THD*) /data/src/10.2/sql/sql_parse.cc:4132
          #21 0x5631fa3731d1 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.2/sql/sql_parse.cc:7793
          #22 0x5631fa34c3d6 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.2/sql/sql_parse.cc:1827
          #23 0x5631fa3491a1 in do_command(THD*) /data/src/10.2/sql/sql_parse.cc:1381
          #24 0x5631fa6d2ed5 in do_handle_one_connection(CONNECT*) /data/src/10.2/sql/sql_connect.cc:1336
          #25 0x5631fa6d2798 in handle_one_connection /data/src/10.2/sql/sql_connect.cc:1241
          #26 0x5631fba785e1 in pfs_spawn_thread /data/src/10.2/storage/perfschema/pfs.cc:1869
          #27 0x7f28f7f1d608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
          #28 0x7f28f7af9292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
      

      10.6 2274c4f5 ASAN

      ==23390==ERROR: AddressSanitizer: heap-use-after-free on address 0x6290002b22a0 at pc 0x55d4b3adbf8e bp 0x7f68d616e470 sp 0x7f68d616e460
      READ of size 1 at 0x6290002b22a0 thread T12
          #0 0x55d4b3adbf8d in my_mb_wc_latin1 /data/src/10.6/strings/ctype-latin1.c:375
          #1 0x55d4b3b45301 in my_convert_using_func /data/src/10.6/strings/ctype.c:1161
          #2 0x55d4b1bee723 in err_conv(char*, unsigned int, char const*, unsigned int, charset_info_st const*) /data/src/10.6/sql/sql_error.cc:915
          #3 0x55d4b1a18cd4 in ErrBuff::set_str(char const*, unsigned long, charset_info_st const*) const /data/src/10.6/sql/sql_error.h:850
          #4 0x55d4b1a190f6 in ErrConvString::lex_cstring() const /data/src/10.6/sql/sql_error.h:888
          #5 0x55d4b27dcacb in field_unpack(String*, Field*, unsigned char const*, unsigned int, bool) /data/src/10.6/sql/key.cc:396
          #6 0x55d4b27dd219 in key_unpack(String*, TABLE*, st_key*) /data/src/10.6/sql/key.cc:441
          #7 0x55d4b251b335 in print_keydup_error(TABLE*, st_key*, char const*, unsigned long) /data/src/10.6/sql/handler.cc:3973
          #8 0x55d4b251b5f0 in print_keydup_error(TABLE*, st_key*, unsigned long) /data/src/10.6/sql/handler.cc:3996
          #9 0x55d4b251bbc6 in handler::print_error(int, unsigned long) /data/src/10.6/sql/handler.cc:4072
          #10 0x55d4b1ffa77a in multi_update::send_data(List<Item>&) /data/src/10.6/sql/sql_update.cc:2680
          #11 0x55d4b1e65268 in select_result_sink::send_data_with_check(List<Item>&, st_select_lex_unit*, unsigned long long) /data/src/10.6/sql/sql_class.h:5582
          #12 0x55d4b1e1ed5d in end_send /data/src/10.6/sql/sql_select.cc:22213
          #13 0x55d4b1e179ec in evaluate_null_complemented_join_record /data/src/10.6/sql/sql_select.cc:21342
          #14 0x55d4b1e15ee7 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.6/sql/sql_select.cc:21040
          #15 0x55d4b1e16e68 in evaluate_join_record /data/src/10.6/sql/sql_select.cc:21219
          #16 0x55d4b1e15e30 in sub_select(JOIN*, st_join_table*, bool) /data/src/10.6/sql/sql_select.cc:21035
          #17 0x55d4b1e139af in do_select /data/src/10.6/sql/sql_select.cc:20543
          #18 0x55d4b1da0714 in JOIN::exec_inner() /data/src/10.6/sql/sql_select.cc:4726
          #19 0x55d4b1d9dbf5 in JOIN::exec() /data/src/10.6/sql/sql_select.cc:4504
          #20 0x55d4b1da2150 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.6/sql/sql_select.cc:4982
          #21 0x55d4b1ff2d10 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.6/sql/sql_update.cc:1960
          #22 0x55d4b1ccae74 in mysql_execute_command(THD*) /data/src/10.6/sql/sql_parse.cc:4480
          #23 0x55d4b1ce3f7a in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/10.6/sql/sql_parse.cc:8016
          #24 0x55d4b1cba100 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/10.6/sql/sql_parse.cc:1897
          #25 0x55d4b1cb6e2d in do_command(THD*, bool) /data/src/10.6/sql/sql_parse.cc:1406
          #26 0x55d4b2119077 in do_handle_one_connection(CONNECT*, bool) /data/src/10.6/sql/sql_connect.cc:1410
          #27 0x55d4b21189d4 in handle_one_connection /data/src/10.6/sql/sql_connect.cc:1312
          #28 0x55d4b2e2a09e in pfs_spawn_thread /data/src/10.6/storage/perfschema/pfs.cc:2201
          #29 0x7f68e594b608 in start_thread /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477
          #30 0x7f68e551f292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
      

      Reproducible on 10.2-10.6 ASAN builds, debug and non-debug.
      No obvious problem on non-ASAN builds, UPDATE returns ER_DUP_KEY as expected.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              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.