From be20b3b03f9c522d17b3454214981506549063eb Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Tue, 21 Dec 2021 16:22:33 -0700 Subject: MDEV-26919: binlog.binlog_truncate_active_log fails in bb with valgrind, Conditional jump or move depends on uninitialised value Problem: ======== When writing an XA based event to the binary log, an assert was always referencing thd->lex->xa_opt. This variable, however, is only set when using XA START, XA END, and XA COMMIT. When an XA PREPARE statement is being processed, it is not guaranteed that the xa_opt variable will be set (e.g. if existing within a stored procedure). This caused valgrind to complain about accessing an uninitialized variable. Solution: ======== Before referencing xa_opt, ensure the context is valid such that it is set. Reviewed By: ============ Andrei Elkin --- sql/log_event_server.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 093adebf536..7c4ea488f9e 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -3281,7 +3281,8 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, (thd->lex->sql_command == SQLCOM_XA_PREPARE || xid_state.get_state_code() == XA_PREPARED)) { - DBUG_ASSERT(thd->lex->xa_opt != XA_ONE_PHASE); + DBUG_ASSERT(!(thd->lex->sql_command == SQLCOM_XA_COMMIT && + thd->lex->xa_opt == XA_ONE_PHASE)); flags2|= thd->lex->sql_command == SQLCOM_XA_PREPARE ? FL_PREPARED_XA : FL_COMPLETED_XA; -- cgit v1.2.1