Skip to content

Commit 09d991d

Browse files
committed
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.
1 parent fb774eb commit 09d991d

File tree

8 files changed

+25
-19
lines changed

8 files changed

+25
-19
lines changed

sql/debug_sync.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end)
10081008
st_debug_sync_action *action= NULL;
10091009
const char *errmsg;
10101010
char *ptr;
1011-
char *token;
1011+
char *token= nullptr;
10121012
uint token_length= 0;
10131013
DBUG_ENTER("debug_sync_eval_action");
10141014
DBUG_ASSERT(thd);

sql/item_func.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Item_func :public Item_func_or_sum,
9090
static void wrong_param_count_error(const LEX_CSTRING &schema_name,
9191
const LEX_CSTRING &func_name);
9292

93-
table_map not_null_tables_cache;
93+
table_map not_null_tables_cache= 0;
9494

9595
enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
9696
GE_FUNC,GT_FUNC,FT_FUNC,

sql/log.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ struct wait_for_commit;
426426

427427
class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
428428
{
429+
#ifdef HAVE_PSI_INTERFACE
429430
/** The instrumentation key to use for @ LOCK_index. */
430431
PSI_mutex_key m_key_LOCK_index;
431432
/** The instrumentation key to use for @ COND_relay_log_updated */
@@ -440,6 +441,16 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
440441
PSI_cond_key m_key_COND_queue_busy;
441442
/** The instrumentation key to use for LOCK_binlog_end_pos. */
442443
PSI_mutex_key m_key_LOCK_binlog_end_pos;
444+
#else
445+
static constexpr PSI_mutex_key m_key_LOCK_index= 0;
446+
static constexpr PSI_cond_key m_key_relay_log_update= 0;
447+
static constexpr PSI_cond_key m_key_bin_log_update= 0;
448+
static constexpr PSI_file_key m_key_file_log= 0, m_key_file_log_cache= 0;
449+
static constexpr PSI_file_key m_key_file_log_index= 0;
450+
static constexpr PSI_file_key m_key_file_log_index_cache= 0;
451+
static constexpr PSI_cond_key m_key_COND_queue_busy= 0;
452+
static constexpr PSI_mutex_key m_key_LOCK_binlog_end_pos= 0;
453+
#endif
443454

444455
struct group_commit_entry
445456
{

sql/multi_range_read.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,6 @@ class DsMrr_impl
556556
public:
557557
typedef void (handler::*range_check_toggle_func_t)(bool on);
558558

559-
DsMrr_impl()
560-
: secondary_file(NULL),
561-
rowid_filter(NULL) {};
562-
563559
void init(handler *h_arg, TABLE *table_arg)
564560
{
565561
primary_file= h_arg;
@@ -581,7 +577,7 @@ class DsMrr_impl
581577
int dsmrr_explain_info(uint mrr_mode, char *str, size_t size);
582578
private:
583579
/* Buffer to store (key, range_id) pairs */
584-
Lifo_buffer *key_buffer;
580+
Lifo_buffer *key_buffer= nullptr;
585581

586582
/*
587583
The "owner" handler object (the one that is expected to "own" this object
@@ -594,13 +590,13 @@ class DsMrr_impl
594590
Secondary handler object. (created when needed, we need it when we need
595591
to run both index scan and rnd_pos() scan at the same time)
596592
*/
597-
handler *secondary_file;
593+
handler *secondary_file= nullptr;
598594

599595
/*
600596
The rowid filter that DS-MRR has "unpushed" from the storage engine.
601597
If it's present, DS-MRR will use it.
602598
*/
603-
Rowid_filter *rowid_filter;
599+
Rowid_filter *rowid_filter= nullptr;
604600

605601
uint keyno; /* index we're running the scan on */
606602
/* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */

sql/sql_lex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3260,7 +3260,7 @@ struct LEX: public Query_tables_list
32603260
Table_type table_type; /* Used for SHOW CREATE */
32613261
List<Key_part_spec> ref_list;
32623262
List<LEX_USER> users_list;
3263-
List<Item> *insert_list,field_list,value_list,update_list;
3263+
List<Item> *insert_list= nullptr,field_list,value_list,update_list;
32643264
List<List_item> many_values;
32653265
List<set_var_base> var_list;
32663266
List<set_var_base> stmt_var_list; //SET_STATEMENT values

storage/innobase/handler/ha_innodb.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12108,7 +12108,7 @@ create_table_info_t::create_foreign_keys()
1210812108
dict_index_t* index = NULL;
1210912109
fkerr_t index_error = FK_SUCCESS;
1211012110
dict_index_t* err_index = NULL;
12111-
ulint err_col;
12111+
ulint err_col = 0;
1211212112
const bool tmp_table = m_flags2 & DICT_TF2_TEMPORARY;
1211312113
const CHARSET_INFO* cs = thd_charset(m_thd);
1211412114
const char* operation = "Create ";
@@ -15150,7 +15150,6 @@ get_foreign_key_info(
1515015150
char tmp_buff[NAME_LEN+1];
1515115151
char name_buff[NAME_LEN+1];
1515215152
const char* ptr;
15153-
LEX_CSTRING* referenced_key_name;
1515415153
LEX_CSTRING* name = NULL;
1515515154

1515615155
if (dict_table_t::is_temporary_name(foreign->foreign_table_name)) {
@@ -15255,18 +15254,16 @@ get_foreign_key_info(
1525515254

1525615255
if (foreign->referenced_index
1525715256
&& foreign->referenced_index->name != NULL) {
15258-
referenced_key_name = thd_make_lex_string(
15257+
f_key_info.referenced_key_name = thd_make_lex_string(
1525915258
thd,
15260-
f_key_info.referenced_key_name,
15259+
nullptr,
1526115260
foreign->referenced_index->name,
1526215261
strlen(foreign->referenced_index->name),
1526315262
1);
1526415263
} else {
15265-
referenced_key_name = NULL;
15264+
f_key_info.referenced_key_name = NULL;
1526615265
}
1526715266

15268-
f_key_info.referenced_key_name = referenced_key_name;
15269-
1527015267
pf_key_info = (FOREIGN_KEY_INFO*) thd_memdup(thd, &f_key_info,
1527115268
sizeof(FOREIGN_KEY_INFO));
1527215269

storage/myisam/ft_boolean_search.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param,
287287
uchar *end= (uchar*) query + len;
288288
FT_WORD w;
289289

290+
w.pos= NULL;
291+
w.len= 0;
290292
info.prev= ' ';
291293
info.quot= 0;
292294
while (ft_get_word(cs, start, end, &w, &info))

tests/mysql_client_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3842,7 +3842,7 @@ static void test_bind_result_ext1()
38423842
short i_data;
38433843
uchar b_data;
38443844
int f_data;
3845-
long bData;
3845+
int bData;
38463846
char d_data[20];
38473847
double szData;
38483848
MYSQL_BIND my_bind[8];
@@ -3938,7 +3938,7 @@ static void test_bind_result_ext1()
39383938
fprintf(stdout, "\n data (float) : %d(%lu)", f_data, length[4]);
39393939
fprintf(stdout, "\n data (double) : %s(%lu)", d_data, length[5]);
39403940

3941-
fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]);
3941+
fprintf(stdout, "\n data (bin) : %d(%lu)", bData, length[6]);
39423942
fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]);
39433943
}
39443944

0 commit comments

Comments
 (0)