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

Uninitialized event size in THD::binlog_query()

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      This push into the main branch introduced a massive test failure:

      12.3 68042221e6a32f44538578d2a11096ca215a4146

      binlog.binlog_index 'mix'                w10 [ fail ]
              Test ended at 2026-01-23 04:05:38
      CURRENT_TEST: binlog.binlog_index
      mysqltest: In included file "./include/not_crashrep.inc": 
      included from /home/buildbot/src/mysql-test/suite/binlog/include/binlog_index.inc at line 17:
      included from /home/buildbot/src/mysql-test/suite/binlog/t/binlog_index.test at line 2:
      At line 29: query 'FLUSH TABLES' failed: <Unknown> (2013): Lost connection to server during query
      Server [mysqld.1 - pid: 977, winpid: 977, exit: 256] failed during test run
      Server log from this test:
      ----------SERVER LOG START-----------
      $ /home/buildbot/bld/sql/mariadbd --defaults-group-suffix=.1 --defaults-file=/dev/shm/normal/10/my.cnf --log-output=file --binlog-format=mixed --log-bin=master-bin --loose-skip-stack-trace --log-warnings=0 --log-bin=master-bin --log-bin-index=master-bin --core-file --loose-debug-sync-timeout=300
      2026-01-23  4:05:36 0 [Note] Starting MariaDB 12.3.0-MariaDB-debug-log source revision 68042221e6a32f44538578d2a11096ca215a4146 server_uid MIoO6lf1+LIM/lET/ZUtWLqNZ50= as process 978
      2026-01-23  4:05:36 0 [Note] Server socket created on IP: '127.0.0.1', port: '19180'.
      2026-01-23  4:05:36 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
      2026-01-23  4:05:36 0 [Note] /home/buildbot/bld/sql/mariadbd: ready for connections.
      Version: '12.3.0-MariaDB-debug-log'  socket: '/dev/shm/normal/tmp/10/mysqld.1.sock'  port: 19180  Source distribution
      ==978==WARNING: MemorySanitizer: use-of-uninitialized-value
          #0 0x55cce6f3b795 in Gtid_log_event::get_size() const /home/buildbot/src/sql/log_event_server.cc:3041:10
          #1 0x55cce6f3f4a4 in Gtid_log_event::write(Log_event_writer*) /home/buildbot/src/sql/log_event_server.cc:3160:3
          #2 0x55cce6e4477f in Log_event_writer::write(Log_event*) /home/buildbot/src/sql/log_event.h:5551:16
          #3 0x55cce6d39ef0 in Event_log::write_event(Log_event*, enum_binlog_checksum_alg, binlog_cache_data*, st_io_cache*) /home/buildbot/src/sql/log.cc:7061:17
          #4 0x55cce6d90bd7 in Event_log::write_event(Log_event*, binlog_cache_data*, st_io_cache*) /home/buildbot/src/sql/log.cc:7043:10
          #5 0x55cce6da8e4b in MYSQL_BIN_LOG::write_gtid_event(THD*, binlog_cache_data*, bool, bool, unsigned long long, bool, bool, bool) /home/buildbot/src/sql/log.cc:8384:7
          #6 0x55cce6db001f in MYSQL_BIN_LOG::write(Log_event*, char*) /home/buildbot/src/sql/log.cc:8792:14
          #7 0x55cce3abeeef in THD::binlog_query(THD::enum_binlog_query_type, char const*, unsigned long, bool, bool, bool, int) /home/buildbot/src/sql/sql_class.cc:8275:30
          #8 0x55cce480769b in write_bin_log(THD*, bool, char const*, unsigned long, bool) /home/buildbot/src/sql/sql_table.cc:1087:17
          #9 0x55cce3f400bf in mysql_execute_command(THD*, bool) /home/buildbot/src/sql/sql_parse.cc:5405:16
          #10 0x55cce3ee516c in mysql_parse(THD*, char*, unsigned int, Parser_state*) /home/buildbot/src/sql/sql_parse.cc:7945:18
          #11 0x55cce3ed26ce in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /home/buildbot/src/sql/sql_parse.cc:1896:7
          #12 0x55cce3eea73a in do_command(THD*, bool) /home/buildbot/src/sql/sql_parse.cc:1432:17
          #13 0x55cce4e86730 in do_handle_one_connection(CONNECT*, bool) /home/buildbot/src/sql/sql_connect.cc:1503:11
          #14 0x55cce4e85029 in handle_one_connection /home/buildbot/src/sql/sql_connect.cc:1415:5
          #15 0x55cce7d31558 in pfs_spawn_thread /home/buildbot/src/storage/perfschema/pfs.cc:2198:3
          #16 0x7f28f85a41f4  (/lib/x86_64-linux-gnu/libc.so.6+0x891f4) (BuildId: 6196744a316dbd57c0fd8968df1680aac482cec4)
          #17 0x7f28f8623b3f in clone (/lib/x86_64-linux-gnu/libc.so.6+0x108b3f) (BuildId: 6196744a316dbd57c0fd8968df1680aac482cec4)
        Uninitialized value was stored to memory at
          #0 0x55cce6f3b78e in Gtid_log_event::get_size() const /home/buildbot/src/sql/log_event_server.cc:3047:34
          #1 0x55cce6f3f4a4 in Gtid_log_event::write(Log_event_writer*) /home/buildbot/src/sql/log_event_server.cc:3160:3
          #2 0x55cce6e4477f in Log_event_writer::write(Log_event*) /home/buildbot/src/sql/log_event.h:5551:16
          #3 0x55cce6d39ef0 in Event_log::write_event(Log_event*, enum_binlog_checksum_alg, binlog_cache_data*, st_io_cache*) /home/buildbot/src/sql/log.cc:7061:17
          #4 0x55cce6d90bd7 in Event_log::write_event(Log_event*, binlog_cache_data*, st_io_cache*) /home/buildbot/src/sql/log.cc:7043:10
          #5 0x55cce6da8e4b in MYSQL_BIN_LOG::write_gtid_event(THD*, binlog_cache_data*, bool, bool, unsigned long long, bool, bool, bool) /home/buildbot/src/sql/log.cc:8384:7
          #6 0x55cce6db001f in MYSQL_BIN_LOG::write(Log_event*, char*) /home/buildbot/src/sql/log.cc:8792:14
          #7 0x55cce3abeeef in THD::binlog_query(THD::enum_binlog_query_type, char const*, unsigned long, bool, bool, bool, int) /home/buildbot/src/sql/sql_class.cc:8275:30
          #8 0x55cce480769b in write_bin_log(THD*, bool, char const*, unsigned long, bool) /home/buildbot/src/sql/sql_table.cc:1087:17
          #9 0x55cce3f400bf in mysql_execute_command(THD*, bool) /home/buildbot/src/sql/sql_parse.cc:5405:16
          #10 0x55cce3ee516c in mysql_parse(THD*, char*, unsigned int, Parser_state*) /home/buildbot/src/sql/sql_parse.cc:7945:18
          #11 0x55cce3ed26ce in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /home/buildbot/src/sql/sql_parse.cc:1896:7
          #12 0x55cce3eea73a in do_command(THD*, bool) /home/buildbot/src/sql/sql_parse.cc:1432:17
          #13 0x55cce4e86730 in do_handle_one_connection(CONNECT*, bool) /home/buildbot/src/sql/sql_connect.cc:1503:11
          #14 0x55cce4e85029 in handle_one_connection /home/buildbot/src/sql/sql_connect.cc:1415:5
          #15 0x55cce7d31558 in pfs_spawn_thread /home/buildbot/src/storage/perfschema/pfs.cc:2198:3
          #16 0x7f28f85a41f4  (/lib/x86_64-linux-gnu/libc.so.6+0x891f4) (BuildId: 6196744a316dbd57c0fd8968df1680aac482cec4)
        Uninitialized value was created by an allocation of 'gtid_event' in the stack frame
          #0 0x55cce6da79a3 in MYSQL_BIN_LOG::write_gtid_event(THD*, binlog_cache_data*, bool, bool, unsigned long long, bool, bool, bool) /home/buildbot/src/sql/log.cc:8344:3
      ...
      Too many tests(20) failed! Terminating...
      Only  128  of 8435 completed.
      --------------------------------------------------------------------------
      The servers were restarted 7 times
      Spent 18.405 of 77 seconds executing testcases
      Too many failed: Failed 21/29 tests, 27.59% were successful.
      Failing test(s): binlog.binlog_index binlog.max_binlog_total_size binlog.binlog_invalid_read_in_rotate binlog.binlog_stm_mix_innodb_myisam binlog.binlog_stm_do_db binlog.binlog_row_annotate binlog.binlog_checksum binlog.binlog_dmls_on_tmp_tables_readonly binlog.binlog_drop_if_exists binlog.binlog_xa_prepared_disconnect binlog.innodb_rc_insert_before_delete binlog.binlog_delete_and_flush_index binlog.binlog_bug36391 binlog.binlog_autocommit_off_no_hang binlog.binlog_mysqlbinlog-cp932 binlog.binlog_show_binlog_event_random_pos binlog.binlog_innodb binlog.binlog_mixed_cache_stat
      

      In the corresponding run for the previous push there were no test failures. The changes between these two pushes are as follows:

      68042221e6a MDEV-38465: Savepoint in trigger causes transactional inconsistency
      7081f2a58ec Binlog-in-engine: New binlog implementation integrated in InnoDB
      d228f237f27 Fix that InnoDB rolls back entire trx in failed CREATE TEMPORARY
      71bf8695bb7 MDEV-38429: Atomic DDL can binlog DDL during ddl log crash recovery without "ddl" mark on the GTID
      b9d60bf4869 MDEV-38429: Atomic DDL can binlog DDL during ddl log crash recovery without "ddl" mark on the GTID
      4528b8a585c MDEV-38629 Deprecate innodb_ft_enable_diag_print variable
      

      A closer inspection limits the list of likely culprits to the following:

      git log --oneline -Sgtid_event ce6be40b79d3b1d84e6dfb23417be77066091ddf..68042221e6a32f44538578d2a11096ca215a4146
      

      7081f2a58ec Binlog-in-engine: New binlog implementation integrated in InnoDB
      71bf8695bb7 MDEV-38429: Atomic DDL can binlog DDL during ddl log crash recovery without "ddl" mark on the GTID
      

      A read of git blame suggests that the exact culprit is MDEV-34705 a.k.a. binlog-in-engine, or the implementation of binlog_storage_engine=innodb.

      Attachments

        Issue Links

          Activity

            People

              knielsen Kristian Nielsen
              marko Marko Mäkelä
              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.