Commit 09d991d0 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-33478: Tests massively fail with clang-18 -fsanitize=memory

Starting with clang-16, MemorySanitizer appears to check that
uninitialized values not be passed by value nor returned.
Previously, it was allowed to copy uninitialized data in such cases.

get_foreign_key_info(): Remove a local variable that was passed
uninitialized to a function.

DsMrr_impl: Initialize key_buffer, because DsMrr_impl::dsmrr_init()
is reading it.

test_bind_result_ext1(): MYSQL_TYPE_LONG is 32 bits, hence we must
use a 32-bit type, such as int. sizeof(long) differs between
LP64 and LLP64 targets.
parent fb774eb1
......@@ -1008,7 +1008,7 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end)
st_debug_sync_action *action= NULL;
const char *errmsg;
char *ptr;
char *token;
char *token= nullptr;
uint token_length= 0;
DBUG_ENTER("debug_sync_eval_action");
DBUG_ASSERT(thd);
......
......@@ -90,7 +90,7 @@ class Item_func :public Item_func_or_sum,
static void wrong_param_count_error(const LEX_CSTRING &schema_name,
const LEX_CSTRING &func_name);
table_map not_null_tables_cache;
table_map not_null_tables_cache= 0;
enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
GE_FUNC,GT_FUNC,FT_FUNC,
......
......@@ -426,6 +426,7 @@ struct wait_for_commit;
class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
{
#ifdef HAVE_PSI_INTERFACE
/** The instrumentation key to use for @ LOCK_index. */
PSI_mutex_key m_key_LOCK_index;
/** The instrumentation key to use for @ COND_relay_log_updated */
......@@ -440,6 +441,16 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
PSI_cond_key m_key_COND_queue_busy;
/** The instrumentation key to use for LOCK_binlog_end_pos. */
PSI_mutex_key m_key_LOCK_binlog_end_pos;
#else
static constexpr PSI_mutex_key m_key_LOCK_index= 0;
static constexpr PSI_cond_key m_key_relay_log_update= 0;
static constexpr PSI_cond_key m_key_bin_log_update= 0;
static constexpr PSI_file_key m_key_file_log= 0, m_key_file_log_cache= 0;
static constexpr PSI_file_key m_key_file_log_index= 0;
static constexpr PSI_file_key m_key_file_log_index_cache= 0;
static constexpr PSI_cond_key m_key_COND_queue_busy= 0;
static constexpr PSI_mutex_key m_key_LOCK_binlog_end_pos= 0;
#endif
struct group_commit_entry
{
......
......@@ -556,10 +556,6 @@ class DsMrr_impl
public:
typedef void (handler::*range_check_toggle_func_t)(bool on);
DsMrr_impl()
: secondary_file(NULL),
rowid_filter(NULL) {};
void init(handler *h_arg, TABLE *table_arg)
{
primary_file= h_arg;
......@@ -581,7 +577,7 @@ class DsMrr_impl
int dsmrr_explain_info(uint mrr_mode, char *str, size_t size);
private:
/* Buffer to store (key, range_id) pairs */
Lifo_buffer *key_buffer;
Lifo_buffer *key_buffer= nullptr;
/*
The "owner" handler object (the one that is expected to "own" this object
......@@ -594,13 +590,13 @@ class DsMrr_impl
Secondary handler object. (created when needed, we need it when we need
to run both index scan and rnd_pos() scan at the same time)
*/
handler *secondary_file;
handler *secondary_file= nullptr;
/*
The rowid filter that DS-MRR has "unpushed" from the storage engine.
If it's present, DS-MRR will use it.
*/
Rowid_filter *rowid_filter;
Rowid_filter *rowid_filter= nullptr;
uint keyno; /* index we're running the scan on */
/* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */
......
......@@ -3260,7 +3260,7 @@ struct LEX: public Query_tables_list
Table_type table_type; /* Used for SHOW CREATE */
List<Key_part_spec> ref_list;
List<LEX_USER> users_list;
List<Item> *insert_list,field_list,value_list,update_list;
List<Item> *insert_list= nullptr,field_list,value_list,update_list;
List<List_item> many_values;
List<set_var_base> var_list;
List<set_var_base> stmt_var_list; //SET_STATEMENT values
......
......@@ -12108,7 +12108,7 @@ create_table_info_t::create_foreign_keys()
dict_index_t* index = NULL;
fkerr_t index_error = FK_SUCCESS;
dict_index_t* err_index = NULL;
ulint err_col;
ulint err_col = 0;
const bool tmp_table = m_flags2 & DICT_TF2_TEMPORARY;
const CHARSET_INFO* cs = thd_charset(m_thd);
const char* operation = "Create ";
......@@ -15150,7 +15150,6 @@ get_foreign_key_info(
char tmp_buff[NAME_LEN+1];
char name_buff[NAME_LEN+1];
const char* ptr;
LEX_CSTRING* referenced_key_name;
LEX_CSTRING* name = NULL;
if (dict_table_t::is_temporary_name(foreign->foreign_table_name)) {
......@@ -15255,18 +15254,16 @@ get_foreign_key_info(
if (foreign->referenced_index
&& foreign->referenced_index->name != NULL) {
referenced_key_name = thd_make_lex_string(
f_key_info.referenced_key_name = thd_make_lex_string(
thd,
f_key_info.referenced_key_name,
nullptr,
foreign->referenced_index->name,
strlen(foreign->referenced_index->name),
1);
} else {
referenced_key_name = NULL;
f_key_info.referenced_key_name = NULL;
}
f_key_info.referenced_key_name = referenced_key_name;
pf_key_info = (FOREIGN_KEY_INFO*) thd_memdup(thd, &f_key_info,
sizeof(FOREIGN_KEY_INFO));
......
......@@ -287,6 +287,8 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param,
uchar *end= (uchar*) query + len;
FT_WORD w;
w.pos= NULL;
w.len= 0;
info.prev= ' ';
info.quot= 0;
while (ft_get_word(cs, start, end, &w, &info))
......
......@@ -3842,7 +3842,7 @@ static void test_bind_result_ext1()
short i_data;
uchar b_data;
int f_data;
long bData;
int bData;
char d_data[20];
double szData;
MYSQL_BIND my_bind[8];
......@@ -3938,7 +3938,7 @@ static void test_bind_result_ext1()
fprintf(stdout, "\n data (float) : %d(%lu)", f_data, length[4]);
fprintf(stdout, "\n data (double) : %s(%lu)", d_data, length[5]);
fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]);
fprintf(stdout, "\n data (bin) : %d(%lu)", bData, length[6]);
fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment