Merge remote-tracking branch 'origin/10.4' into 10.5

This commit is contained in:
Monty 2020-07-03 23:31:12 +03:00
commit 0fd89a1a89
40 changed files with 182 additions and 173 deletions

View File

@ -24,16 +24,22 @@
# define __SANITIZE_ADDRESS__ 1 # define __SANITIZE_ADDRESS__ 1
#endif #endif
#ifdef HAVE_valgrind #if __has_feature(memory_sanitizer)
#define IF_VALGRIND(A,B) A # include <sanitizer/msan_interface.h>
#else # define HAVE_valgrind
#define IF_VALGRIND(A,B) B # define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
#endif # define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
#if defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind) # define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
# define REDZONE_SIZE 8
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h> # include <valgrind/memcheck.h>
# define HAVE_valgrind_or_MSAN
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len) # define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len) # define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len) # define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len) # define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
@ -45,27 +51,19 @@
# include <sanitizer/asan_interface.h> # include <sanitizer/asan_interface.h>
/* How to do manual poisoning: /* How to do manual poisoning:
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len) # define MEM_UNDEFINED(a,len) ((void) 0)
# define MEM_MAKE_ADDRESSABLE(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
# define MEM_MAKE_DEFINED(a,len) ((void) 0) # define MEM_MAKE_DEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len) # define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0) # define MEM_CHECK_ADDRESSABLE(a,len) \
assert(!__asan_region_is_poisoned((void*) a,len))
# define MEM_CHECK_DEFINED(a,len) ((void) 0) # define MEM_CHECK_DEFINED(a,len) ((void) 0)
# define MEM_GET_VBITS(a,b,len) ((void) 0) # define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0) # define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 8 # define REDZONE_SIZE 8
#elif __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define HAVE_valgrind_or_MSAN
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
# define REDZONE_SIZE 8
#else #else
# define MEM_UNDEFINED(a,len) ((void) (a), (void) (len)) # define MEM_UNDEFINED(a,len) ((void) 0)
# define MEM_MAKE_ADDRESSABLE(a,len) ((void) 0)
# define MEM_MAKE_DEFINED(a,len) ((void) 0) # define MEM_MAKE_DEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ((void) 0) # define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0) # define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
@ -73,25 +71,30 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_GET_VBITS(a,b,len) ((void) 0) # define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0) # define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 0 # define REDZONE_SIZE 0
#endif /* HAVE_VALGRIND_MEMCHECK_H */ #endif /* __has_feature(memory_sanitizer) */
#ifdef HAVE_valgrind
#define IF_VALGRIND(A,B) A
#else
#define IF_VALGRIND(A,B) B
#endif
#ifdef TRASH_FREED_MEMORY #ifdef TRASH_FREED_MEMORY
/* /*
TRASH_FILL() has to call MEM_UNDEFINED() to cancel any effect of TRASH_FREE(). _TRASH_FILL() has to call MEM_MAKE_ADDRESSABLE() to cancel any effect of
TRASH_FREE().
This can happen in the case one does This can happen in the case one does
TRASH_ALLOC(A,B) ; TRASH_FREE(A,B) ; TRASH_ALLOC(A,B) TRASH_ALLOC(A,B) ; TRASH_FREE(A,B) ; TRASH_ALLOC(A,B)
to reuse the same memory in an internal memory allocator like MEM_ROOT. to reuse the same memory in an internal memory allocator like MEM_ROOT.
For my_malloc() and safemalloc() the extra MEM_UNDEFINED is bit of an _TRASH_FILL() is an internal function and should not be used externally.
overkill.
TRASH_FILL() is an internal function and should not be used externally.
*/ */
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0) #define _TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_MAKE_ADDRESSABLE(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else #else
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0) #define _TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
#endif #endif
/** Note that some memory became allocated or uninitialized. */ /** Note that some memory became allocated and/or uninitialized. */
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0) #define TRASH_ALLOC(A,B) do { _TRASH_FILL(A,B,0xA5); MEM_MAKE_ADDRESSABLE(A,B); } while(0)
/** Note that some memory became freed. (Prohibit further access to it.) */ /** Note that some memory became freed. (Prohibit further access to it.) */
#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0) #define TRASH_FREE(A,B) do { _TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
#endif /* MY_VALGRIND_INCLUDED */ #endif /* MY_VALGRIND_INCLUDED */

View File

@ -1164,6 +1164,7 @@ my_bool STDCALL mysql_embedded(void)
void my_net_local_init(NET *net) void my_net_local_init(NET *net)
{ {
net->max_packet= (uint) net_buffer_length; net->max_packet= (uint) net_buffer_length;
net->read_timeout= net->write_timeout= 0;
my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT); my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT); my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
net->retry_count= 1; net->retry_count= 1;

View File

@ -17,7 +17,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
file_exists $MYSQLD_DATADIR/mysql_upgrade_info; file_exists $MYSQLD_DATADIR/mysql_upgrade_info;
--echo Run it again - should say already completed --echo Run it again - should say already completed
--replace_result $MYSQL_SERVER_VERSION VERSION --replace_regex /upgraded to .*, use/upgraded to VERSION, use/
--exec $MYSQL_UPGRADE 2>&1 --exec $MYSQL_UPGRADE 2>&1
# It should have created a file in the MySQL Servers datadir # It should have created a file in the MySQL Servers datadir

View File

@ -173,6 +173,9 @@ ERROR 22007: Truncated incorrect datetime value: '0000-00-00 00:00:00'
DROP TABLE t1,t2; DROP TABLE t1,t2;
SET sql_mode=DEFAULT; SET sql_mode=DEFAULT;
# #
# End of 10.3 tests
#
#
# MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv # MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
# #
CREATE TABLE t1 (f TIMESTAMP DEFAULT 0) ENGINE=InnoDB; CREATE TABLE t1 (f TIMESTAMP DEFAULT 0) ENGINE=InnoDB;

View File

@ -82,6 +82,9 @@ CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6)
DROP TABLE t1,t2; DROP TABLE t1,t2;
SET sql_mode=DEFAULT; SET sql_mode=DEFAULT;
--echo #
--echo # End of 10.3 tests
--echo #
--echo # --echo #
--echo # MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv --echo # MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
@ -92,7 +95,6 @@ INSERT INTO t1 VALUES ('2024-02-29');
SELECT * FROM t1 WHERE SUBSTR(1 FROM BIT_LENGTH(f) FOR DEFAULT(f)); SELECT * FROM t1 WHERE SUBSTR(1 FROM BIT_LENGTH(f) FOR DEFAULT(f));
DROP TABLE t1; DROP TABLE t1;
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #

View File

@ -1,3 +1,4 @@
--source include/not_as_root.inc
# #
# MDEV-11883 MariaDB crashes with out-of-memory when query information_schema # MDEV-11883 MariaDB crashes with out-of-memory when query information_schema
# #

View File

@ -0,0 +1,12 @@
connection node_2;
connection node_1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
LOCK TABLES t2 READ;
ERROR 42S02: Table 'test.t2' doesn't exist
START TRANSACTION;
INSERT INTO t1 VALUES (1);
LOCK TABLES t1 READ;
UNLOCK TABLES;
DROP TABLE t1;

View File

@ -0,0 +1,21 @@
#
# Check `LOCK TABLES` command with or without existing table in database.
# Test case for MDEV-22222 / MDEV-22223
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
--error ER_NO_SUCH_TABLE
LOCK TABLES t2 READ;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
LOCK TABLES t1 READ;
UNLOCK TABLES;
DROP TABLE t1;

View File

@ -205,7 +205,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
uchar* point; uchar* point;
reg1 USED_MEM *next= 0; reg1 USED_MEM *next= 0;
reg2 USED_MEM **prev; reg2 USED_MEM **prev;
size_t original_length = length; size_t original_length __attribute__((unused)) = length;
DBUG_ENTER("alloc_root"); DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root))); DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root)));
DBUG_ASSERT(alloc_root_inited(mem_root)); DBUG_ASSERT(alloc_root_inited(mem_root));

View File

@ -7698,7 +7698,7 @@ my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value)
} }
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
void Field_varstring::mark_unused_memory_as_defined() void Field_varstring::mark_unused_memory_as_defined()
{ {
uint used_length= get_length(); uint used_length= get_length();

View File

@ -997,7 +997,7 @@ public:
*/ */
virtual int store_from_statistical_minmax_field(Field *field, String *str); virtual int store_from_statistical_minmax_field(Field *field, String *str);
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
/** /**
Mark unused memory in the field as defined. Mainly used to ensure Mark unused memory in the field as defined. Mainly used to ensure
that if we write full field to disk (for example in that if we write full field to disk (for example in
@ -4136,7 +4136,7 @@ public:
} }
int store(const char *to,size_t length,CHARSET_INFO *charset) override; int store(const char *to,size_t length,CHARSET_INFO *charset) override;
using Field_str::store; using Field_str::store;
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
void mark_unused_memory_as_defined() override; void mark_unused_memory_as_defined() override;
#endif #endif
double val_real() override; double val_real() override;

View File

@ -381,16 +381,14 @@ bool Session_sysvars_tracker::enable(THD *thd)
bool Session_sysvars_tracker::update(THD *thd, set_var *var) bool Session_sysvars_tracker::update(THD *thd, set_var *var)
{ {
vars_list tool_list; vars_list tool_list;
void *copy;
size_t length= 1; size_t length= 1;
if (var->save_result.string_value.str) void *copy= var->save_result.string_value.str ?
copy= my_memdup(PSI_INSTRUMENT_ME, var->save_result.string_value.str, my_memdup(PSI_INSTRUMENT_ME, var->save_result.string_value.str,
(length= var->save_result.string_value.length + 1), (length= var->save_result.string_value.length + 1),
MYF(MY_WME | MY_THREAD_SPECIFIC)) :
my_strdup(PSI_INSTRUMENT_ME, "",
MYF(MY_WME | MY_THREAD_SPECIFIC)); MYF(MY_WME | MY_THREAD_SPECIFIC));
else
copy= my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME | MY_THREAD_SPECIFIC));
if (!copy) if (!copy)
return true; return true;

View File

@ -2029,8 +2029,8 @@ int READ_INFO::read_xml(THD *thd)
case '=': /* attribute name end - read the value */ case '=': /* attribute name end - read the value */
//check for tag field and attribute name //check for tag field and attribute name
if(!memcmp(tag.c_ptr_safe(), STRING_WITH_LEN("field")) && if(!strcmp(tag.c_ptr_safe(), "field") &&
!memcmp(attribute.c_ptr_safe(), STRING_WITH_LEN("name"))) !strcmp(attribute.c_ptr_safe(), "name"))
{ {
/* /*
this is format <field name="xx">xx</field> this is format <field name="xx">xx</field>

View File

@ -5058,6 +5058,12 @@ mysql_execute_command(THD *thd)
if (res) if (res)
goto error; goto error;
#ifdef WITH_WSREP
/* Clean up the previous transaction on implicit commit. */
if (wsrep_on(thd) && !wsrep_not_committed(thd) && wsrep_after_statement(thd))
goto error;
#endif
/* We can't have any kind of table locks while backup is active */ /* We can't have any kind of table locks while backup is active */
if (thd->current_backup_stage != BACKUP_FINISHED) if (thd->current_backup_stage != BACKUP_FINISHED)
{ {

View File

@ -6562,6 +6562,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
keyuse.keypart= FT_KEYPART; keyuse.keypart= FT_KEYPART;
keyuse.used_tables=cond_func->key_item()->used_tables(); keyuse.used_tables=cond_func->key_item()->used_tables();
keyuse.optimize= 0; keyuse.optimize= 0;
keyuse.ref_table_rows= 0;
keyuse.keypart_map= 0; keyuse.keypart_map= 0;
keyuse.sj_pred_no= UINT_MAX; keyuse.sj_pred_no= UINT_MAX;
keyuse.validity_ref= 0; keyuse.validity_ref= 0;
@ -18641,17 +18642,15 @@ bool Create_tmp_table::finalize(THD *thd,
uint null_pack_length[2]; uint null_pack_length[2];
uint null_pack_base[2]; uint null_pack_base[2];
uint null_counter[2]= {0, 0}; uint null_counter[2]= {0, 0};
uint whole_null_pack_length; uint whole_null_pack_length;
bool use_packed_rows= false; bool use_packed_rows= false;
bool save_abort_on_warning;
uchar *pos; uchar *pos;
uchar *null_flags; uchar *null_flags;
KEY *keyinfo; KEY *keyinfo;
TMP_ENGINE_COLUMNDEF *recinfo; TMP_ENGINE_COLUMNDEF *recinfo;
TABLE_SHARE *share= table->s; TABLE_SHARE *share= table->s;
Copy_field *copy= param->copy_field; Copy_field *copy= param->copy_field;
MEM_ROOT *mem_root_save= thd->mem_root; MEM_ROOT *mem_root_save= thd->mem_root;
thd->mem_root= &table->mem_root; thd->mem_root= &table->mem_root;
@ -18752,6 +18751,11 @@ bool Create_tmp_table::finalize(THD *thd,
{ {
null_counter[(m_field_count[other] ? other : distinct)]++; null_counter[(m_field_count[other] ? other : distinct)]++;
} }
/* Protect against warnings in field_conv() in the next loop*/
save_abort_on_warning= thd->abort_on_warning;
thd->abort_on_warning= 0;
for (uint i= 0; i < share->fields; i++, recinfo++) for (uint i= 0; i < share->fields; i++, recinfo++)
{ {
Field *field= table->field[i]; Field *field= table->field[i];
@ -18795,16 +18799,22 @@ bool Create_tmp_table::finalize(THD *thd,
inherit the default value that is defined for the field referred inherit the default value that is defined for the field referred
by the Item_field object from which 'field' has been created. by the Item_field object from which 'field' has been created.
*/ */
const Field *orig_field= m_default_field[i]; Field *orig_field= m_default_field[i];
/* Get the value from default_values */ /* Get the value from default_values */
if (orig_field->is_null_in_record(orig_field->table->s->default_values)) if (orig_field->is_null_in_record(orig_field->table->s->default_values))
field->set_null(); field->set_null();
else else
{ {
/*
Copy default value. We have to use field_conv() for copy, instead of
memcpy(), because bit_fields may be stored differently
*/
my_ptrdiff_t ptr_diff= (orig_field->table->s->default_values -
orig_field->table->record[0]);
field->set_notnull(); field->set_notnull();
memcpy(field->ptr, orig_field->move_field_offset(ptr_diff);
orig_field->ptr_in_record(orig_field->table->s->default_values), field_conv(field, orig_field);
field->pack_length_in_rec()); orig_field->move_field_offset(-ptr_diff);
} }
} }
@ -18813,7 +18823,7 @@ bool Create_tmp_table::finalize(THD *thd,
copy->set(field, m_from_field[i], m_save_sum_fields); copy->set(field, m_from_field[i], m_save_sum_fields);
copy++; copy++;
} }
length=field->pack_length(); length=field->pack_length_in_rec();
pos+= length; pos+= length;
/* Make entry for create table */ /* Make entry for create table */
@ -18823,7 +18833,11 @@ bool Create_tmp_table::finalize(THD *thd,
// fix table name in field entry // fix table name in field entry
field->set_table_name(&table->alias); field->set_table_name(&table->alias);
} }
/* Handle group_null_items */
bzero(pos, table->s->reclength - (pos - table->record[0]));
MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
thd->abort_on_warning= save_abort_on_warning;
param->copy_field_end= copy; param->copy_field_end= copy;
param->recinfo= recinfo; // Pointer to after last field param->recinfo= recinfo; // Pointer to after last field
store_record(table,s->default_values); // Make empty default record store_record(table,s->default_values); // Make empty default record
@ -19086,8 +19100,9 @@ bool Create_tmp_table::finalize(THD *thd,
goto err; goto err;
} }
// Make empty record so random data is not written to disk /* record[0] and share->default_values should now have been set up */
empty_record(table); MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
MEM_CHECK_DEFINED(share->default_values, table->s->reclength);
thd->mem_root= mem_root_save; thd->mem_root= mem_root_save;
@ -19483,6 +19498,10 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
(*recinfo)->type= FIELD_CHECK; (*recinfo)->type= FIELD_CHECK;
(*recinfo)->length= MARIA_UNIQUE_HASH_LENGTH; (*recinfo)->length= MARIA_UNIQUE_HASH_LENGTH;
(*recinfo)++; (*recinfo)++;
/* Avoid warnings from valgrind */
bzero(table->record[0]+ share->reclength, MARIA_UNIQUE_HASH_LENGTH);
bzero(share->default_values+ share->reclength, MARIA_UNIQUE_HASH_LENGTH);
share->reclength+= MARIA_UNIQUE_HASH_LENGTH; share->reclength+= MARIA_UNIQUE_HASH_LENGTH;
} }
else else
@ -19677,6 +19696,9 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
(*recinfo)->type= FIELD_CHECK; (*recinfo)->type= FIELD_CHECK;
(*recinfo)->length=MI_UNIQUE_HASH_LENGTH; (*recinfo)->length=MI_UNIQUE_HASH_LENGTH;
(*recinfo)++; (*recinfo)++;
/* Avoid warnings from valgrind */
bzero(table->record[0]+ share->reclength, MI_UNIQUE_HASH_LENGTH);
bzero(share->default_values+ share->reclength, MI_UNIQUE_HASH_LENGTH);
share->reclength+= MI_UNIQUE_HASH_LENGTH; share->reclength+= MI_UNIQUE_HASH_LENGTH;
} }
else else
@ -20269,11 +20291,11 @@ bool instantiate_tmp_table(TABLE *table, KEY *keyinfo,
If it is not heap (in-memory) table then convert index to unique If it is not heap (in-memory) table then convert index to unique
constrain. constrain.
*/ */
MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
if (create_internal_tmp_table(table, keyinfo, start_recinfo, recinfo, if (create_internal_tmp_table(table, keyinfo, start_recinfo, recinfo,
options)) options))
return TRUE; return TRUE;
// Make empty record so random data is not written to disk MEM_CHECK_DEFINED(table->record[0], table->s->reclength);
empty_record(table);
} }
if (open_tmp_table(table)) if (open_tmp_table(table))
return TRUE; return TRUE;
@ -28795,7 +28817,6 @@ AGGR_OP::prepare_tmp_table()
join->select_options)) join->select_options))
return true; return true;
(void) table->file->extra(HA_EXTRA_WRITE_CACHE); (void) table->file->extra(HA_EXTRA_WRITE_CACHE);
empty_record(table);
} }
/* If it wasn't already, start index scan for grouping using table index. */ /* If it wasn't already, start index scan for grouping using table index. */
if (!table->file->inited && table->group && if (!table->file->inited && table->group &&

View File

@ -2109,8 +2109,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
share->rec_buff_length= rec_buff_length; share->rec_buff_length= rec_buff_length;
if (!(record= (uchar *) alloc_root(&share->mem_root, rec_buff_length))) if (!(record= (uchar *) alloc_root(&share->mem_root, rec_buff_length)))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
MEM_NOACCESS(record, rec_buff_length); /* Mark bytes after record as not accessable to catch overrun bugs */
MEM_UNDEFINED(record, share->reclength); MEM_NOACCESS(record + share->reclength, rec_buff_length - share->reclength);
share->default_values= record; share->default_values= record;
memcpy(record, frm_image + record_offset, share->reclength); memcpy(record, frm_image + record_offset, share->reclength);
@ -3959,7 +3959,6 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
if (!(record= (uchar*) alloc_root(&outparam->mem_root, if (!(record= (uchar*) alloc_root(&outparam->mem_root,
share->rec_buff_length * records))) share->rec_buff_length * records)))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
MEM_NOACCESS(record, share->rec_buff_length * records);
} }
for (i= 0; i < 3;) for (i= 0; i < 3;)
@ -3968,8 +3967,10 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
if (++i < records) if (++i < records)
record+= share->rec_buff_length; record+= share->rec_buff_length;
} }
/* Mark bytes between records as not accessable to catch overrun bugs */
for (i= 0; i < records; i++) for (i= 0; i < records; i++)
MEM_UNDEFINED(outparam->record[i], share->reclength); MEM_NOACCESS(outparam->record[i] + share->reclength,
share->rec_buff_length - share->reclength);
if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root, if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
(uint) ((share->fields+1)* (uint) ((share->fields+1)*

View File

@ -592,8 +592,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
pos+= create_info->comment.length; pos+= create_info->comment.length;
} }
memcpy(frm_ptr + filepos, forminfo, 288); memcpy(frm_ptr + filepos, forminfo, FRM_FORMINFO_SIZE);
pos= frm_ptr + filepos + 288; pos= frm_ptr + filepos + FRM_FORMINFO_SIZE;
if (pack_fields(&pos, create_fields, create_info, data_offset)) if (pack_fields(&pos, create_fields, create_info, data_offset))
goto err; goto err;

View File

@ -1299,12 +1299,10 @@ btr_cur_search_to_nth_level_func(
ut_ad(!(index->type & DICT_FTS)); ut_ad(!(index->type & DICT_FTS));
ut_ad(index->page != FIL_NULL); ut_ad(index->page != FIL_NULL);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&cursor->up_match, sizeof cursor->up_match); MEM_UNDEFINED(&cursor->up_match, sizeof cursor->up_match);
MEM_UNDEFINED(&cursor->up_bytes, sizeof cursor->up_bytes); MEM_UNDEFINED(&cursor->up_bytes, sizeof cursor->up_bytes);
MEM_UNDEFINED(&cursor->low_match, sizeof cursor->low_match); MEM_UNDEFINED(&cursor->low_match, sizeof cursor->low_match);
MEM_UNDEFINED(&cursor->low_bytes, sizeof cursor->low_bytes); MEM_UNDEFINED(&cursor->low_bytes, sizeof cursor->low_bytes);
#endif /* HAVE_valgrind_or_MSAN */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
cursor->up_match = ULINT_UNDEFINED; cursor->up_match = ULINT_UNDEFINED;
cursor->low_match = ULINT_UNDEFINED; cursor->low_match = ULINT_UNDEFINED;
@ -3367,12 +3365,12 @@ btr_cur_optimistic_insert(
|| (flags & BTR_CREATE_FLAG)); || (flags & BTR_CREATE_FLAG));
ut_ad(dtuple_check_typed(entry)); ut_ad(dtuple_check_typed(entry));
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
if (block->page.zip.data) { if (block->page.zip.data) {
MEM_CHECK_DEFINED(page, srv_page_size); MEM_CHECK_DEFINED(page, srv_page_size);
MEM_CHECK_DEFINED(block->page.zip.data, block->zip_size()); MEM_CHECK_DEFINED(block->page.zip.data, block->zip_size());
} }
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
leaf = page_is_leaf(page); leaf = page_is_leaf(page);

View File

@ -364,9 +364,7 @@ buf_buddy_block_free(void* buf)
HASH_DELETE(buf_page_t, hash, &buf_pool.zip_hash, fold, bpage); HASH_DELETE(buf_page_t, hash, &buf_pool.zip_hash, fold, bpage);
ut_d(memset(buf, 0, srv_page_size)); ut_d(memset(buf, 0, srv_page_size));
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(buf, srv_page_size); MEM_UNDEFINED(buf, srv_page_size);
#endif /* HAVE_valgrind_or_MSAN */
block = (buf_block_t*) bpage; block = (buf_block_t*) bpage;
buf_LRU_block_free_non_file_page(block); buf_LRU_block_free_non_file_page(block);

View File

@ -1356,6 +1356,8 @@ inline bool buf_pool_t::chunk_t::create(size_t bytes)
if (UNIV_UNLIKELY(!mem)) if (UNIV_UNLIKELY(!mem))
return false; return false;
MEM_MAKE_ADDRESSABLE(mem, mem_size());
#ifdef HAVE_LIBNUMA #ifdef HAVE_LIBNUMA
if (srv_numa_interleave) if (srv_numa_interleave)
{ {
@ -1736,9 +1738,7 @@ inline bool buf_pool_t::realloc(buf_block_t *block)
"not perfect alignment"); "not perfect alignment");
memset_aligned<2>(block->frame memset_aligned<2>(block->frame
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4); + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(block->frame, srv_page_size); MEM_UNDEFINED(block->frame, srv_page_size);
#endif /* HAVE_valgrind_or_MSAN */
block->page.set_state(BUF_BLOCK_REMOVE_HASH); block->page.set_state(BUF_BLOCK_REMOVE_HASH);
/* Relocate flush_list. */ /* Relocate flush_list. */
@ -2257,6 +2257,8 @@ withdraw_retry:
ulint sum_freed = 0; ulint sum_freed = 0;
while (chunk < echunk) { while (chunk < echunk) {
MEM_MAKE_ADDRESSABLE(chunk->mem, chunk->size);
buf_block_t* block = chunk->blocks; buf_block_t* block = chunk->blocks;
for (ulint j = chunk->size; j--; block++) { for (ulint j = chunk->size; j--; block++) {
@ -3382,9 +3384,7 @@ evict_from_pool:
block->page.set_io_fix(BUF_IO_READ); block->page.set_io_fix(BUF_IO_READ);
rw_lock_x_lock_inline(&block->lock, 0, file, line); rw_lock_x_lock_inline(&block->lock, 0, file, line);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(bpage, sizeof *bpage); MEM_UNDEFINED(bpage, sizeof *bpage);
#endif /* HAVE_valgrind_or_MSAN */
mutex_exit(&buf_pool.mutex); mutex_exit(&buf_pool.mutex);
hash_lock->write_unlock(); hash_lock->write_unlock();

View File

@ -626,7 +626,7 @@ buf_block_t* buf_LRU_get_free_only()
assert_block_ahi_empty(block); assert_block_ahi_empty(block);
block->page.set_state(BUF_BLOCK_MEMORY); block->page.set_state(BUF_BLOCK_MEMORY);
MEM_UNDEFINED(block->frame, srv_page_size); MEM_MAKE_ADDRESSABLE(block->frame, srv_page_size);
break; break;
} }
@ -1307,13 +1307,9 @@ func_exit:
order to avoid bogus Valgrind or MSAN warnings.*/ order to avoid bogus Valgrind or MSAN warnings.*/
buf_block_t* block = reinterpret_cast<buf_block_t*>(bpage); buf_block_t* block = reinterpret_cast<buf_block_t*>(bpage);
#ifdef HAVE_valgrind_or_MSAN
MEM_MAKE_DEFINED(block->frame, srv_page_size); MEM_MAKE_DEFINED(block->frame, srv_page_size);
#endif /* HAVE_valgrind_or_MSAN */
btr_search_drop_page_hash_index(block); btr_search_drop_page_hash_index(block);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(block->frame, srv_page_size); MEM_UNDEFINED(block->frame, srv_page_size);
#endif /* HAVE_valgrind_or_MSAN */
if (UNIV_LIKELY_NULL(b)) { if (UNIV_LIKELY_NULL(b)) {
ut_ad(b->zip_size()); ut_ad(b->zip_size());
@ -1511,9 +1507,7 @@ static bool buf_LRU_block_remove_hashed(buf_page_t *bpage, const page_id_t id,
"not perfect alignment"); "not perfect alignment");
memset_aligned<2>(reinterpret_cast<buf_block_t*>(bpage)->frame memset_aligned<2>(reinterpret_cast<buf_block_t*>(bpage)->frame
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4); + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(((buf_block_t*) bpage)->frame, srv_page_size); MEM_UNDEFINED(((buf_block_t*) bpage)->frame, srv_page_size);
#endif /* HAVE_valgrind_or_MSAN */
bpage->set_state(BUF_BLOCK_REMOVE_HASH); bpage->set_state(BUF_BLOCK_REMOVE_HASH);
/* Question: If we release hash_lock here /* Question: If we release hash_lock here

View File

@ -234,7 +234,7 @@ dtuple_validate(
const dtuple_t* tuple) /*!< in: tuple */ const dtuple_t* tuple) /*!< in: tuple */
{ {
ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N); ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N);
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
const ulint n_fields = dtuple_get_n_fields(tuple); const ulint n_fields = dtuple_get_n_fields(tuple);
for (ulint i = 0; i < n_fields; i++) { for (ulint i = 0; i < n_fields; i++) {
@ -245,7 +245,7 @@ dtuple_validate(
dfield_get_len(field)); dfield_get_len(field));
} }
} }
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
ut_ad(dtuple_check_typed(tuple)); ut_ad(dtuple_check_typed(tuple));
return(TRUE); return(TRUE);

View File

@ -7033,9 +7033,7 @@ build_template_field(
ut_ad(clust_index->table == index->table); ut_ad(clust_index->table == index->table);
templ = prebuilt->mysql_template + prebuilt->n_template++; templ = prebuilt->mysql_template + prebuilt->n_template++;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(templ, sizeof *templ); MEM_UNDEFINED(templ, sizeof *templ);
#endif /* HAVE_valgrind_or_MSAN */
templ->is_virtual = !field->stored_in_db(); templ->is_virtual = !field->stored_in_db();
if (!templ->is_virtual) { if (!templ->is_virtual) {
@ -8146,9 +8144,7 @@ calc_row_difference(
/* The field has changed */ /* The field has changed */
ufield = uvect->fields + n_changed; ufield = uvect->fields + n_changed;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(ufield, sizeof *ufield); MEM_UNDEFINED(ufield, sizeof *ufield);
#endif /* HAVE_valgrind_or_MSAN */
/* Let us use a dummy dfield to make the conversion /* Let us use a dummy dfield to make the conversion
from the MySQL column format to the InnoDB format */ from the MySQL column format to the InnoDB format */

View File

@ -185,9 +185,7 @@ buf_page_alloc_descriptor(void)
bpage = (buf_page_t*) ut_zalloc_nokey(sizeof *bpage); bpage = (buf_page_t*) ut_zalloc_nokey(sizeof *bpage);
ut_ad(bpage); ut_ad(bpage);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(bpage, sizeof *bpage); MEM_UNDEFINED(bpage, sizeof *bpage);
#endif /* HAVE_valgrind_or_MSAN */
return(bpage); return(bpage);
} }

View File

@ -187,7 +187,7 @@ dict_stats_deinit(
table->stat_initialized = FALSE; table->stat_initialized = FALSE;
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
MEM_UNDEFINED(&table->stat_n_rows, sizeof table->stat_n_rows); MEM_UNDEFINED(&table->stat_n_rows, sizeof table->stat_n_rows);
MEM_UNDEFINED(&table->stat_clustered_index_size, MEM_UNDEFINED(&table->stat_clustered_index_size,
sizeof table->stat_clustered_index_size); sizeof table->stat_clustered_index_size);
@ -220,7 +220,7 @@ dict_stats_deinit(
&index->stat_n_leaf_pages, &index->stat_n_leaf_pages,
sizeof(index->stat_n_leaf_pages)); sizeof(index->stat_n_leaf_pages));
} }
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
rw_lock_x_unlock(&table->stats_latch); rw_lock_x_unlock(&table->stats_latch);
} }

View File

@ -203,7 +203,7 @@ mem_heap_alloc(
mem_block_set_free(block, free + MEM_SPACE_NEEDED(n)); mem_block_set_free(block, free + MEM_SPACE_NEEDED(n));
buf = buf + REDZONE_SIZE; buf = buf + REDZONE_SIZE;
MEM_UNDEFINED(buf, n - REDZONE_SIZE); MEM_MAKE_ADDRESSABLE(buf, n - REDZONE_SIZE);
return(buf); return(buf);
} }

View File

@ -651,14 +651,14 @@ Use MONITOR_DEC if appropriate mutex protection exists.
} \ } \
} }
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
# define MONITOR_CHECK_DEFINED(value) do { \ # define MONITOR_CHECK_DEFINED(value) do { \
mon_type_t m = value; \ mon_type_t m = value; \
MEM_CHECK_DEFINED(&m, sizeof m); \ MEM_CHECK_DEFINED(&m, sizeof m); \
} while (0) } while (0)
#else /* HAVE_valgrind_or_MSAN */ #else /* HAVE_valgrind */
# define MONITOR_CHECK_DEFINED(value) (void) 0 # define MONITOR_CHECK_DEFINED(value) (void) 0
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
#define MONITOR_INC_VALUE(monitor, value) \ #define MONITOR_INC_VALUE(monitor, value) \
MONITOR_CHECK_DEFINED(value); \ MONITOR_CHECK_DEFINED(value); \

View File

@ -89,13 +89,12 @@ struct Pool {
ut_ad(elem->m_pool == this); ut_ad(elem->m_pool == this);
#ifdef __SANITIZE_ADDRESS__ #ifdef __SANITIZE_ADDRESS__
/* Unpoison the memory for AddressSanitizer */ /* Unpoison the memory for AddressSanitizer */
MEM_UNDEFINED(&elem->m_type, sizeof elem->m_type); MEM_MAKE_ADDRESSABLE(&elem->m_type,
sizeof elem->m_type);
#endif #endif
#ifdef HAVE_valgrind /* Declare the contents initialized;
/* Declare the contents as initialized for Valgrind;
we checked this in mem_free(). */ we checked this in mem_free(). */
MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type); MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type);
#endif
Factory::destroy(&elem->m_type); Factory::destroy(&elem->m_type);
} }
@ -134,14 +133,13 @@ struct Pool {
if (elem) { if (elem) {
# ifdef __SANITIZE_ADDRESS__ # ifdef __SANITIZE_ADDRESS__
/* Unpoison the memory for AddressSanitizer */ /* Unpoison the memory for AddressSanitizer */
MEM_UNDEFINED(&elem->m_type, sizeof elem->m_type); MEM_MAKE_ADDRESSABLE(&elem->m_type,
sizeof elem->m_type);
# endif # endif
# ifdef HAVE_valgrind /* Declare the memory initialized.
/* Declare the memory initialized for Valgrind.
The trx_t that are released to the pool are The trx_t that are released to the pool are
actually initialized; we checked that by actually initialized; we checked that by
MEM_CHECK_DEFINED() in mem_free() below. */ MEM_CHECK_DEFINED() in mem_free() below. */
# endif
MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type); MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type);
} }
#endif #endif

View File

@ -354,10 +354,9 @@ struct mtr_write_log_t {
/** Start a mini-transaction. */ /** Start a mini-transaction. */
void mtr_t::start() void mtr_t::start()
{ {
#ifdef HAVE_valgrind_or_MSAN ut_ad(!m_freed_pages);
MEM_UNDEFINED(this, sizeof *this); MEM_UNDEFINED(this, sizeof *this);
MEM_MAKE_DEFINED(&m_freed_pages, sizeof(m_freed_pages)); MEM_MAKE_DEFINED(&m_freed_pages, sizeof(m_freed_pages));
#endif /* HAVE_valgrind_or_MSAN */
ut_d(m_start= true); ut_d(m_start= true);
ut_d(m_commit= false); ut_d(m_commit= false);
@ -376,7 +375,6 @@ void mtr_t::start()
m_user_space= nullptr; m_user_space= nullptr;
m_commit_lsn= 0; m_commit_lsn= 0;
m_freed_in_system_tablespace= m_trim_pages= false; m_freed_in_system_tablespace= m_trim_pages= false;
ut_ad(!m_freed_pages);
} }
/** Release the resources */ /** Release the resources */

View File

@ -1302,7 +1302,7 @@ page_cur_insert_rec_low(
/* 1. Get the size of the physical record in the page */ /* 1. Get the size of the physical record in the page */
const ulint rec_size= rec_offs_size(offsets); const ulint rec_size= rec_offs_size(offsets);
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
{ {
const void *rec_start= rec - rec_offs_extra_size(offsets); const void *rec_start= rec - rec_offs_extra_size(offsets);
ulint extra_size= rec_offs_extra_size(offsets) - ulint extra_size= rec_offs_extra_size(offsets) -
@ -1314,7 +1314,7 @@ page_cur_insert_rec_low(
/* The variable-length header must be valid. */ /* The variable-length header must be valid. */
MEM_CHECK_DEFINED(rec_start, extra_size); MEM_CHECK_DEFINED(rec_start, extra_size);
} }
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
/* 2. Try to find suitable space from page memory management */ /* 2. Try to find suitable space from page memory management */
bool reuse= false; bool reuse= false;
@ -1702,7 +1702,7 @@ page_cur_insert_rec_zip(
/* 1. Get the size of the physical record in the page */ /* 1. Get the size of the physical record in the page */
const ulint rec_size= rec_offs_size(offsets); const ulint rec_size= rec_offs_size(offsets);
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
{ {
const void *rec_start= rec - rec_offs_extra_size(offsets); const void *rec_start= rec - rec_offs_extra_size(offsets);
ulint extra_size= rec_offs_extra_size(offsets) - REC_N_NEW_EXTRA_BYTES; ulint extra_size= rec_offs_extra_size(offsets) - REC_N_NEW_EXTRA_BYTES;
@ -1711,7 +1711,7 @@ page_cur_insert_rec_zip(
/* The variable-length header must be valid. */ /* The variable-length header must be valid. */
MEM_CHECK_DEFINED(rec_start, extra_size); MEM_CHECK_DEFINED(rec_start, extra_size);
} }
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
const bool reorg_before_insert= page_has_garbage(cursor->block->frame) && const bool reorg_before_insert= page_has_garbage(cursor->block->frame) &&
rec_size > page_get_max_insert_size(cursor->block->frame, 1) && rec_size > page_get_max_insert_size(cursor->block->frame, 1) &&
rec_size <= page_get_max_insert_size_after_reorganize(cursor->block->frame, rec_size <= page_get_max_insert_size_after_reorganize(cursor->block->frame,

View File

@ -1552,11 +1552,11 @@ err_exit:
ut_ad(buf + c_stream.total_out == c_stream.next_out); ut_ad(buf + c_stream.total_out == c_stream.next_out);
ut_ad((ulint) (storage - c_stream.next_out) >= c_stream.avail_out); ut_ad((ulint) (storage - c_stream.next_out) >= c_stream.avail_out);
#ifdef HAVE_valgrind #if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
/* Valgrind believes that zlib does not initialize some bits /* Valgrind believes that zlib does not initialize some bits
in the last 7 or 8 bytes of the stream. Make Valgrind happy. */ in the last 7 or 8 bytes of the stream. Make Valgrind happy. */
MEM_MAKE_DEFINED(buf, c_stream.total_out); MEM_MAKE_DEFINED(buf, c_stream.total_out);
#endif /* HAVE_valgrind */ #endif /* HAVE_valgrind && !memory_sanitizer */
/* Zero out the area reserved for the modification log. /* Zero out the area reserved for the modification log.
Space for the end marker of the modification log is not Space for the end marker of the modification log is not
@ -3076,9 +3076,7 @@ page_zip_decompress_low(
/* Clear the uncompressed page, except the header. */ /* Clear the uncompressed page, except the header. */
memset(PAGE_DATA + page, 0x55, srv_page_size - PAGE_DATA); memset(PAGE_DATA + page, 0x55, srv_page_size - PAGE_DATA);
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(PAGE_DATA + page, srv_page_size - PAGE_DATA); MEM_UNDEFINED(PAGE_DATA + page, srv_page_size - PAGE_DATA);
#endif /* HAVE_valgrind_or_MSAN */
/* Copy the page directory. */ /* Copy the page directory. */
if (UNIV_UNLIKELY(!page_zip_dir_decode(page_zip, page, recs, if (UNIV_UNLIKELY(!page_zip_dir_decode(page_zip, page, recs,

View File

@ -982,14 +982,14 @@ exit:
goto func_exit; goto func_exit;
} }
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
MEM_UNDEFINED(block[i], srv_sort_buf_size); MEM_UNDEFINED(block[i], srv_sort_buf_size);
if (crypt_block[i]) { if (crypt_block[i]) {
MEM_UNDEFINED(crypt_block[i], MEM_UNDEFINED(crypt_block[i],
srv_sort_buf_size); srv_sort_buf_size);
} }
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
} }
buf[i] = row_merge_buf_empty(buf[i]); buf[i] = row_merge_buf_empty(buf[i]);

View File

@ -1240,10 +1240,8 @@ row_ins_foreign_check_on_constraint(
update->info_bits = 0; update->info_bits = 0;
update->n_fields = foreign->n_fields; update->n_fields = foreign->n_fields;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(update->fields, MEM_UNDEFINED(update->fields,
update->n_fields * sizeof *update->fields); update->n_fields * sizeof *update->fields);
#endif /* HAVE_valgrind_or_MSAN */
bool affects_fulltext = false; bool affects_fulltext = false;

View File

@ -375,9 +375,7 @@ row_log_online_op(
goto err_exit; goto err_exit;
} }
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf); MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
#endif /* HAVE_valgrind_or_MSAN */
ut_ad(log->tail.bytes < srv_sort_buf_size); ut_ad(log->tail.bytes < srv_sort_buf_size);
avail_size = srv_sort_buf_size - log->tail.bytes; avail_size = srv_sort_buf_size - log->tail.bytes;
@ -462,10 +460,8 @@ write_failed:
index->type |= DICT_CORRUPT; index->type |= DICT_CORRUPT;
} }
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.block, srv_sort_buf_size); MEM_UNDEFINED(log->tail.block, srv_sort_buf_size);
MEM_UNDEFINED(buf, srv_sort_buf_size); MEM_UNDEFINED(buf, srv_sort_buf_size);
#endif /* HAVE_valgrind_or_MSAN */
memcpy(log->tail.block, log->tail.buf + avail_size, memcpy(log->tail.block, log->tail.buf + avail_size,
mrec_size - avail_size); mrec_size - avail_size);
@ -475,9 +471,7 @@ write_failed:
ut_ad(b == log->tail.block + log->tail.bytes); ut_ad(b == log->tail.block + log->tail.bytes);
} }
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf); MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
#endif /* HAVE_valgrind_or_MSAN */
err_exit: err_exit:
mutex_exit(&log->mutex); mutex_exit(&log->mutex);
} }
@ -509,9 +503,7 @@ row_log_table_open(
{ {
mutex_enter(&log->mutex); mutex_enter(&log->mutex);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf); MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
#endif /* HAVE_valgrind_or_MSAN */
if (log->error != DB_SUCCESS) { if (log->error != DB_SUCCESS) {
err_exit: err_exit:
@ -603,10 +595,9 @@ row_log_table_close_func(
write_failed: write_failed:
log->error = DB_ONLINE_LOG_TOO_BIG; log->error = DB_ONLINE_LOG_TOO_BIG;
} }
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.block, srv_sort_buf_size); MEM_UNDEFINED(log->tail.block, srv_sort_buf_size);
MEM_UNDEFINED(buf, srv_sort_buf_size); MEM_UNDEFINED(buf, srv_sort_buf_size);
#endif /* HAVE_valgrind_or_MSAN */
memcpy(log->tail.block, log->tail.buf + avail, size - avail); memcpy(log->tail.block, log->tail.buf + avail, size - avail);
log->tail.bytes = size - avail; log->tail.bytes = size - avail;
} else { } else {
@ -615,9 +606,7 @@ write_failed:
} }
log->tail.total += size; log->tail.total += size;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf); MEM_UNDEFINED(log->tail.buf, sizeof log->tail.buf);
#endif /* HAVE_valgrind_or_MSAN */
err_exit: err_exit:
mutex_exit(&log->mutex); mutex_exit(&log->mutex);
@ -2789,9 +2778,7 @@ row_log_table_apply_ops(
ut_ad(new_trx_id_col > 0); ut_ad(new_trx_id_col > 0);
ut_ad(new_trx_id_col != ULINT_UNDEFINED); ut_ad(new_trx_id_col != ULINT_UNDEFINED);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&mrec_end, sizeof mrec_end); MEM_UNDEFINED(&mrec_end, sizeof mrec_end);
#endif /* HAVE_valgrind_or_MSAN */
offsets = static_cast<rec_offs*>(ut_malloc_nokey(i * sizeof *offsets)); offsets = static_cast<rec_offs*>(ut_malloc_nokey(i * sizeof *offsets));
rec_offs_set_n_alloc(offsets, i); rec_offs_set_n_alloc(offsets, i);
@ -3703,9 +3690,8 @@ row_log_apply_ops(
ut_ad(!index->is_committed()); ut_ad(!index->is_committed());
ut_ad(rw_lock_own(dict_index_get_lock(index), RW_LOCK_X)); ut_ad(rw_lock_own(dict_index_get_lock(index), RW_LOCK_X));
ut_ad(index->online_log); ut_ad(index->online_log);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&mrec_end, sizeof mrec_end); MEM_UNDEFINED(&mrec_end, sizeof mrec_end);
#endif /* HAVE_valgrind_or_MSAN */
offsets = static_cast<rec_offs*>(ut_malloc_nokey(i * sizeof *offsets)); offsets = static_cast<rec_offs*>(ut_malloc_nokey(i * sizeof *offsets));
rec_offs_set_n_alloc(offsets, i); rec_offs_set_n_alloc(offsets, i);

View File

@ -1021,11 +1021,11 @@ row_merge_buf_write(
ut_a(b < &block[srv_sort_buf_size]); ut_a(b < &block[srv_sort_buf_size]);
ut_a(b == &block[0] + buf->total_size); ut_a(b == &block[0] + buf->total_size);
*b++ = 0; *b++ = 0;
#ifdef HAVE_valgrind_or_MSAN #ifdef HAVE_valgrind
/* The rest of the block is uninitialized. Initialize it /* The rest of the block is uninitialized. Initialize it
to avoid bogus warnings. */ to avoid bogus warnings. */
memset(b, 0xff, &block[srv_sort_buf_size] - b); memset(b, 0xff, &block[srv_sort_buf_size] - b);
#endif /* HAVE_valgrind_or_MSAN */ #endif /* HAVE_valgrind */
DBUG_LOG("ib_merge_sort", DBUG_LOG("ib_merge_sort",
"write " << reinterpret_cast<const void*>(b) << ',' "write " << reinterpret_cast<const void*>(b) << ','
<< of->fd << ',' << of->offset << " EOF"); << of->fd << ',' << of->offset << " EOF");
@ -1418,9 +1418,7 @@ row_merge_write_rec(
return(NULL); return(NULL);
} }
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&block[0], srv_sort_buf_size); MEM_UNDEFINED(&block[0], srv_sort_buf_size);
#endif /* HAVE_valgrind_or_MSAN */
/* Copy the rest. */ /* Copy the rest. */
b = &block[0]; b = &block[0];
@ -1471,9 +1469,7 @@ row_merge_write_eof(
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&block[0], srv_sort_buf_size); MEM_UNDEFINED(&block[0], srv_sort_buf_size);
#endif
DBUG_RETURN(&block[0]); DBUG_RETURN(&block[0]);
} }
@ -2661,10 +2657,8 @@ write_buffers:
break; break;
} }
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED( MEM_UNDEFINED(
&block[0], srv_sort_buf_size); &block[0], srv_sort_buf_size);
#endif /* HAVE_valgrind_or_MSAN */
} }
} }
merge_buf[i] = row_merge_buf_empty(buf); merge_buf[i] = row_merge_buf_empty(buf);
@ -3164,9 +3158,7 @@ row_merge(
foffs0 = 0; foffs0 = 0;
foffs1 = ihalf; foffs1 = ihalf;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(run_offset, *num_run * sizeof *run_offset); MEM_UNDEFINED(run_offset, *num_run * sizeof *run_offset);
#endif /* HAVE_valgrind_or_MSAN */
for (; foffs0 < ihalf && foffs1 < file->offset; foffs0++, foffs1++) { for (; foffs0 < ihalf && foffs1 < file->offset; foffs0++, foffs1++) {
@ -3247,9 +3239,7 @@ row_merge(
*tmpfd = file->fd; *tmpfd = file->fd;
*file = of; *file = of;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&block[0], 3 * srv_sort_buf_size); MEM_UNDEFINED(&block[0], 3 * srv_sort_buf_size);
#endif /* HAVE_valgrind_or_MSAN */
return(DB_SUCCESS); return(DB_SUCCESS);
} }

View File

@ -974,11 +974,9 @@ row_sel_get_clust_rec(
switch (err) { switch (err) {
case DB_SUCCESS: case DB_SUCCESS:
case DB_SUCCESS_LOCKED_REC: case DB_SUCCESS_LOCKED_REC:
#ifdef HAVE_valgrind_or_MSAN
/* Declare the variable uninitialized. /* Declare the variable uninitialized.
It should be set to DB_SUCCESS at func_exit. */ It should be set to DB_SUCCESS at func_exit. */
MEM_UNDEFINED(&err, sizeof err); MEM_UNDEFINED(&err, sizeof err);
#endif /* HAVE_valgrind_or_MSAN */
break; break;
default: default:
goto err_exit; goto err_exit;
@ -2686,9 +2684,7 @@ row_sel_field_store_in_mysql_format_func(
ut_ad(len != UNIV_SQL_NULL); ut_ad(len != UNIV_SQL_NULL);
MEM_CHECK_DEFINED(data, len); MEM_CHECK_DEFINED(data, len);
MEM_CHECK_ADDRESSABLE(dest, templ->mysql_col_len); MEM_CHECK_ADDRESSABLE(dest, templ->mysql_col_len);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(dest, templ->mysql_col_len); MEM_UNDEFINED(dest, templ->mysql_col_len);
#endif /* HAVE_valgrind_or_MSAN */
byte* pad = dest + len; byte* pad = dest + len;
@ -3615,9 +3611,7 @@ row_sel_copy_cached_field_for_mysql(
row_mysql_read_true_varchar( row_mysql_read_true_varchar(
&len, cache, templ->mysql_length_bytes); &len, cache, templ->mysql_length_bytes);
len += templ->mysql_length_bytes; len += templ->mysql_length_bytes;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(buf, templ->mysql_col_len); MEM_UNDEFINED(buf, templ->mysql_col_len);
#endif /* HAVE_valgrind_or_MSAN */
} else { } else {
len = templ->mysql_col_len; len = templ->mysql_col_len;
} }
@ -3693,9 +3687,7 @@ row_sel_dequeue_cached_row_for_mysql(
/* The record is long. Copy it field by field, in case /* The record is long. Copy it field by field, in case
there are some long VARCHAR column of which only a there are some long VARCHAR column of which only a
small length is being used. */ small length is being used. */
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(buf, prebuilt->mysql_prefix_len); MEM_UNDEFINED(buf, prebuilt->mysql_prefix_len);
#endif /* HAVE_valgrind_or_MSAN */
/* First copy the NULL bits. */ /* First copy the NULL bits. */
memcpy(buf, cached_rec, prebuilt->null_bitmap_len); memcpy(buf, cached_rec, prebuilt->null_bitmap_len);
@ -3779,10 +3771,8 @@ row_sel_fetch_last_buf(
} }
ut_ad(prebuilt->fetch_cache_first == 0); ut_ad(prebuilt->fetch_cache_first == 0);
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(prebuilt->fetch_cache[prebuilt->n_fetch_cached], MEM_UNDEFINED(prebuilt->fetch_cache[prebuilt->n_fetch_cached],
prebuilt->mysql_row_len); prebuilt->mysql_row_len);
#endif /* HAVE_valgrind_or_MSAN */
return(prebuilt->fetch_cache[prebuilt->n_fetch_cached]); return(prebuilt->fetch_cache[prebuilt->n_fetch_cached]);
} }

View File

@ -1542,9 +1542,7 @@ row_upd_changes_ord_field_binary_func(
/* Silence a compiler warning without /* Silence a compiler warning without
silencing a Valgrind error. */ silencing a Valgrind error. */
dfield_len = 0; dfield_len = 0;
#ifdef HAVE_valgrind_or_MSAN
MEM_UNDEFINED(&dfield_len, sizeof dfield_len); MEM_UNDEFINED(&dfield_len, sizeof dfield_len);
#endif /* HAVE_valgrind_or_MSAN */
/* See if the column is stored externally. */ /* See if the column is stored externally. */
buf = row_ext_lookup(ext, col_no, &dfield_len); buf = row_ext_lookup(ext, col_no, &dfield_len);

View File

@ -891,7 +891,7 @@ sync_array_print_long_waits_low(
return(false); return(false);
} }
#ifdef HAVE_valgrind #if defined HAVE_valgrind && !__has_feature(memory_sanitizer)
/* Increase the timeouts if running under valgrind because it executes /* Increase the timeouts if running under valgrind because it executes
extremely slowly. HAVE_valgrind does not necessary mean that extremely slowly. HAVE_valgrind does not necessary mean that
we are running under valgrind but we have no better way to tell. we are running under valgrind but we have no better way to tell.

View File

@ -454,15 +454,11 @@ void trx_free(trx_t*& trx)
#ifdef __SANITIZE_ADDRESS__ #ifdef __SANITIZE_ADDRESS__
/* Unpoison the memory for innodb_monitor_set_option; /* Unpoison the memory for innodb_monitor_set_option;
it is operating also on the freed transaction objects. */ it is operating also on the freed transaction objects. */
MEM_UNDEFINED(&trx->mutex, sizeof trx->mutex); MEM_MAKE_ADDRESSABLE(&trx->mutex, sizeof trx->mutex);
/* For innobase_kill_connection() */ /* For innobase_kill_connection() */
# ifdef WITH_WSREP MEM_MAKE_ADDRESSABLE(&trx->state, sizeof trx->state);
MEM_UNDEFINED(&trx->wsrep, sizeof trx->wsrep); MEM_MAKE_ADDRESSABLE(&trx->mysql_thd, sizeof trx->mysql_thd);
#endif #endif
MEM_UNDEFINED(&trx->state, sizeof trx->state);
MEM_UNDEFINED(&trx->mysql_thd, sizeof trx->mysql_thd);
#endif
#ifdef HAVE_valgrind_or_MSAN
/* Unpoison the memory for innodb_monitor_set_option; /* Unpoison the memory for innodb_monitor_set_option;
it is operating also on the freed transaction objects. it is operating also on the freed transaction objects.
We checked that these were initialized in We checked that these were initialized in
@ -474,7 +470,6 @@ void trx_free(trx_t*& trx)
# endif # endif
MEM_MAKE_DEFINED(&trx->state, sizeof trx->state); MEM_MAKE_DEFINED(&trx->state, sizeof trx->state);
MEM_MAKE_DEFINED(&trx->mysql_thd, sizeof trx->mysql_thd); MEM_MAKE_DEFINED(&trx->mysql_thd, sizeof trx->mysql_thd);
#endif
trx = NULL; trx = NULL;
} }

View File

@ -6123,6 +6123,11 @@ void ha_tokudb::position(const uchar * record) {
// //
memcpy(ref, &key.size, sizeof(uint32_t)); memcpy(ref, &key.size, sizeof(uint32_t));
} }
/*
tokudb doesn't always write the last byte. Don't that cause problems with
MariaDB
*/
MEM_MAKE_DEFINED(ref, ref_length);
TOKUDB_HANDLER_DBUG_VOID_RETURN; TOKUDB_HANDLER_DBUG_VOID_RETURN;
} }