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

ASAN use-after-poison in dtuple_dup_v_fld() from row_undo_mod_sec_is_unsafe() on ROLLBACK, gcol.innodb_virtual_basic fails

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      gcol.innodb_virtual_basic fails on the builder amd64-ubasan-clang-22 for 11.8, because AddressSanitizer reports a use-after-poison during a ROLLBACK, in dtuple_dup_v_fld() called from row_undo_mod_sec_is_unsafe(). The server aborts, and the test loses its connection. In each of the two builds below, the first and the third attempt failed this way, and the second passed.

      • 11.8 075616233, server version 11.8.10: build 4740, 2026-11-03.
      • PR #6170 on 11.8 77071d2a4bd, server version 11.8.11: build 5412. The PR does not change InnoDB.

      How to repeat

      On an ASAN build of 11.8:

      ./mtr gcol.innodb_virtual_basic
      

      The failure is intermittent. The statement that fails is the ROLLBACK at line 47 of suite/gcol/inc/innodb_v_large_col.inc, which innodb_virtual_basic.test includes at line 775:

      mysqltest: In included file "/home/buildbot/src/mysql-test/suite/gcol/inc/innodb_v_large_col.inc":
      included from /home/buildbot/src/mysql-test/suite/gcol/t/innodb_virtual_basic.test at line 775:
      At line 47: query 'ROLLBACK' failed: <Unknown> (2013): Lost connection to server during query
      

      The statements just before it:

      CALL UPDATE_t();
      CALL DELETE_insert_t();
      UPDATE t SET a = NULL WHERE h=1;
      START TRANSACTION;
      CALL UPDATE_t();
      ROLLBACK;
      

      where UPDATE_t() runs UPDATE t SET a = REPEAT(CAST(i AS CHAR), 2000) WHERE h = 1 for i from 1 to 100, and DELETE_insert_t() deletes and inserts the row with h = 1 100 times.

      The report from build 4740:

      ==357649==ERROR: AddressSanitizer: use-after-poison on address 0x736095925620 at pc 0x555c3f047dcf bp 0x73608a439df0 sp 0x73608a4395b0
      READ of size 768 at 0x736095925620 thread T11
          #0 0x555c3f047dce in __asan_memcpy (/home/buildbot/bld/sql/mariadbd+0x15c9dce)
          #1 0x555c40c16dbe in mem_heap_dup(mem_block_info_t*, void const*, unsigned long) /home/buildbot/src/storage/innobase/include/mem0mem.h:208:5
          #2 0x555c40c16dbe in dfield_dup(dfield_t*, mem_block_info_t*) /home/buildbot/src/storage/innobase/include/data0data.inl:170:17
          #3 0x555c40c16dbe in dtuple_dup_v_fld(dtuple_t*, mem_block_info_t*) /home/buildbot/src/storage/innobase/include/data0data.inl:342:3
          #4 0x555c40c16dbe in row_undo_mod_sec_is_unsafe(unsigned char const*, dict_index_t*, dtuple_t const*, mtr_t*) /home/buildbot/src/storage/innobase/row/row0umod.cc:565:5
          #5 0x555c40c16dbe in row_undo_mod_del_mark_or_remove_sec_low(undo_node_t*, que_thr_t*, dict_index_t*, dtuple_t*, btr_latch_mode) /home/buildbot/src/storage/innobase/row/row0umod.cc:745:9
          #6 0x555c40c0fe62 in row_undo_mod_del_mark_or_remove_sec(undo_node_t*, que_thr_t*, dict_index_t*, dtuple_t*) /home/buildbot/src/storage/innobase/row/row0umod.cc:811:8
          #7 0x555c40c0fe62 in row_undo_mod_upd_exist_sec(undo_node_t*, que_thr_t*) /home/buildbot/src/storage/innobase/row/row0umod.cc:1184:10
          #8 0x555c40c0fe62 in row_undo_mod(undo_node_t*, que_thr_t*) /home/buildbot/src/storage/innobase/row/row0umod.cc:1386:10
          #9 0x555c40c1be46 in row_undo(undo_node_t*, que_thr_t*) /home/buildbot/src/storage/innobase/row/row0undo.cc:401:31
          #10 0x555c40c1be46 in row_undo_step(que_thr_t*) /home/buildbot/src/storage/innobase/row/row0undo.cc:442:8
          #11 0x555c40af0611 in que_thr_step(que_thr_t*) /home/buildbot/src/storage/innobase/que/que0que.cc:551:9
          #12 0x555c40af0611 in que_run_threads_low(que_thr_t*) /home/buildbot/src/storage/innobase/que/que0que.cc:609:25
          #13 0x555c40af0611 in que_run_threads(que_thr_t*) /home/buildbot/src/storage/innobase/que/que0que.cc:629:2
          #14 0x555c40c9408e in trx_t::rollback_low(unsigned long const*) /home/buildbot/src/storage/innobase/trx/trx0roll.cc:124:5
          #15 0x555c40c9521c in trx_rollback_for_mysql(trx_t*) /home/buildbot/src/storage/innobase/trx/trx0roll.cc:223:15
          #16 0x555c40949c3b in innobase_rollback(THD*, bool) /home/buildbot/src/storage/innobase/handler/ha_innodb.cc:4712:14
          #17 0x555c3fe09a9b in ha_rollback_trans(THD*, bool) /home/buildbot/src/sql/handler.cc:2430:37
          #18 0x555c3f97bc02 in trans_rollback(THD*) /home/buildbot/src/sql/transaction.cc:386:8
          #19 0x555c3f47cf53 in mysql_execute_command(THD*, bool) /home/buildbot/src/sql/sql_parse.cc:5609:27
       
      Address 0x736095925620 is a wild pointer inside of access range of size 0x000000000300.
      SUMMARY: AddressSanitizer: use-after-poison (/home/buildbot/bld/sql/mariadbd+0x15c9dce) in __asan_memcpy
      

      Build 5412 has the same stack, with a read of 768 bytes from row0umod.cc:565.

      The code

      row_undo_mod_sec_is_unsafe() in storage/innobase/row/row0umod.cc, where it walks the older versions of the clustered index record for an index on a virtual column:

      		if (dict_index_has_virtual(index)) {
      			if (vrow) {
      				if (dtuple_vcol_data_missing(*vrow, *index)) {
      					goto nochange_index;
      				}
      				/* Keep the virtual row info for the next
      				version, unless it is changed */
      				mem_heap_empty(v_heap);
      				cur_vrow = dtuple_copy(vrow, v_heap);
      				dtuple_dup_v_fld(cur_vrow, v_heap);
      			}
      

      dtuple_dup_v_fld() copies the data of every virtual field of cur_vrow into v_heap with dfield_dup(), and the read of 768 bytes is one of these copies.

      Affected versions

      Seen on 11.8 only. The call to dtuple_dup_v_fld() in row_undo_mod_sec_is_unsafe() came with MDEV-34515. MDEV-26951 reports another failure of gcol.innodb_virtual_basic, the "purge non-delete-marked" error.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              arcivanov Arcadiy Ivanov
              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.