Skip to content

Commit

Permalink
MDEV-22806: MSAN reports use-of-uninitialized-value for rpl_parallel_…
Browse files Browse the repository at this point in the history
…conflicts.test

Problem:
========
Relay_log_info::flush reports following MSAN issue.
==17820==WARNING: MemorySanitizer: use-of-uninitialized-value is reported
#5  0x00005584f0981441 in my_write (Filedes=22,
Buffer=0x72500003e818 "5\n./slave-relay-bin.000003\n21385\n
master-bin.000001\n21643\n0\n", '\245' <repeats 141 times>..., Count=118,
MyFlags=532) at /home/sujatha/bug_repo/test-10.5-msan/mysys/my_write.c:49

Analysis:
=========
In parallel replication at the end of each statement execution the worker execution
status is updated in 'relay-log.info' file. When two workers try to flush
the status at the same time, since the write to cache is not serialized both
workers write to the same address simultaneously and increment the
length twice. Because of this the length of buffer is more than actual data.
When flush code tries to read the buffer beyond valid data length MSAN
reports uninitialized values error.

Fix:
===
Serialize the relay log flush operation using "rli->data_lock".
  • Loading branch information
sujatha-s committed Jun 25, 2020
1 parent bebc576 commit 3bc8939
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sql/rpl_rli.cc
Expand Up @@ -1445,8 +1445,14 @@ bool Relay_log_info::stmt_done(my_off_t event_master_log_pos, THD *thd,
}
DBUG_EXECUTE_IF("inject_crash_before_flush_rli", DBUG_SUICIDE(););
if (mi->using_gtid == Master_info::USE_GTID_NO)
{
if (rgi->is_parallel_exec)
mysql_mutex_lock(&data_lock);
if (flush_relay_log_info(this))
error= 1;
if (rgi->is_parallel_exec)
mysql_mutex_unlock(&data_lock);
}
DBUG_EXECUTE_IF("inject_crash_after_flush_rli", DBUG_SUICIDE(););
}
DBUG_RETURN(error);
Expand Down

0 comments on commit 3bc8939

Please sign in to comment.