diff options
author | unknown <sven@murkla.(none)> | 2007-10-03 11:57:14 +0200 |
---|---|---|
committer | unknown <sven@murkla.(none)> | 2007-10-03 11:57:14 +0200 |
commit | 42cea00e036c1191b7c9251ac1e123df8273d86c (patch) | |
tree | bae6731479e92ca246615a36384166804e2b4e35 /sql/sql_repl.cc | |
parent | eefbdfdb03fdebdf43fa41095f5b635146e7a00d (diff) | |
download | mariadb-git-42cea00e036c1191b7c9251ac1e123df8273d86c.tar.gz |
BUG#30752 rpl_dual_pos_advance valgrind (jump depends on uninitialized LOG_INFO)
Problem: one thread could read uninitialized memory from (the stack of) another
thread.
Fix: swapped order of initializing the memory and making it available to the
other thread.
Fix: put lock around the statement that makes the memory available to the other
thread.
Fix: all fields of the struct are now initialized in the constructor, to avoid
future problems.
sql/sql_class.h:
Initialize all members in constructor for more safe future code.
sql/sql_repl.cc:
Swap order so that linfo is first initialized, then assigned, instead of the
other way around.
Put a lock around the assignment. We use LOCK_thread_count since log_in_use
uses it: log_in_use may be running concurrently, called from
MYSQL_LOG::purge_logs.
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 9cc0ba7c29a..903d254db8f 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -364,7 +364,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, name=0; // Find first log linfo.index_file_offset = 0; - thd->current_linfo = &linfo; if (mysql_bin_log.find_log_pos(&linfo, name, 1)) { @@ -373,6 +372,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, goto err; } + pthread_mutex_lock(&LOCK_thread_count); + thd->current_linfo = &linfo; + pthread_mutex_unlock(&LOCK_thread_count); + if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0) { my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; @@ -1338,7 +1341,6 @@ bool mysql_show_binlog_events(THD* thd) name=0; // Find first log linfo.index_file_offset = 0; - thd->current_linfo = &linfo; if (mysql_bin_log.find_log_pos(&linfo, name, 1)) { @@ -1346,6 +1348,10 @@ bool mysql_show_binlog_events(THD* thd) goto err; } + pthread_mutex_lock(&LOCK_thread_count); + thd->current_linfo = &linfo; + pthread_mutex_unlock(&LOCK_thread_count); + if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0) goto err; |