diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-02 09:41:44 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-02 09:41:44 +0300 |
commit | 1813d92d0c505a1c752f4a9d6e37db6bffe4efdd (patch) | |
tree | f570314890197949ae55cbbad3a94eb5893c4177 /storage/innobase/include | |
parent | 0fe97c20b341665058491fca4d665207406775c6 (diff) | |
parent | f347b3e0e6592329b1447fa460aca0a4b1f680b1 (diff) | |
download | mariadb-git-1813d92d0c505a1c752f4a9d6e37db6bffe4efdd.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/buf0buf.h | 2 | ||||
-rw-r--r-- | storage/innobase/include/buf0buf.ic | 4 | ||||
-rw-r--r-- | storage/innobase/include/data0data.ic | 18 | ||||
-rw-r--r-- | storage/innobase/include/dict0stats.ic | 35 | ||||
-rw-r--r-- | storage/innobase/include/fts0fts.h | 11 | ||||
-rw-r--r-- | storage/innobase/include/mem0mem.ic | 6 | ||||
-rw-r--r-- | storage/innobase/include/page0zip.ic | 2 | ||||
-rw-r--r-- | storage/innobase/include/read0types.h | 4 | ||||
-rw-r--r-- | storage/innobase/include/rem0rec.h | 16 | ||||
-rw-r--r-- | storage/innobase/include/rem0rec.ic | 2 | ||||
-rw-r--r-- | storage/innobase/include/srv0mon.h | 10 | ||||
-rw-r--r-- | storage/innobase/include/univ.i | 60 | ||||
-rw-r--r-- | storage/innobase/include/ut0pool.h | 9 |
13 files changed, 56 insertions, 123 deletions
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 4e0b25c52dd..e316e1b7dab 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1156,7 +1156,7 @@ struct buf_block_t{ # define assert_block_ahi_empty(block) \ ut_a((block)->n_pointers == 0) # define assert_block_ahi_empty_on_init(block) do { \ - UNIV_MEM_VALID(&(block)->n_pointers, sizeof (block)->n_pointers); \ + MEM_MAKE_DEFINED(&(block)->n_pointers, sizeof (block)->n_pointers); \ assert_block_ahi_empty(block); \ } while (0) # define assert_block_ahi_valid(block) \ diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index c264ae07ff8..242c9cbb65d 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -185,7 +185,9 @@ buf_page_alloc_descriptor(void) bpage = (buf_page_t*) ut_zalloc_nokey(sizeof *bpage); ut_ad(bpage); - UNIV_MEM_ALLOC(bpage, sizeof *bpage); +#ifdef HAVE_valgrind_or_MSAN + MEM_UNDEFINED(bpage, sizeof *bpage); +#endif /* HAVE_valgrind_or_MSAN */ return(bpage); } diff --git a/storage/innobase/include/data0data.ic b/storage/innobase/include/data0data.ic index 857ffc15d76..2d1bf5a2d50 100644 --- a/storage/innobase/include/data0data.ic +++ b/storage/innobase/include/data0data.ic @@ -51,10 +51,6 @@ dfield_set_len( ulint len) /*!< in: length or UNIV_SQL_NULL */ { ut_ad(len != UNIV_SQL_DEFAULT); -#ifdef UNIV_VALGRIND_DEBUG - if (len != UNIV_SQL_NULL) UNIV_MEM_ASSERT_RW(field->data, len); -#endif /* UNIV_VALGRIND_DEBUG */ - field->ext = 0; field->len = static_cast<unsigned int>(len); } @@ -94,9 +90,6 @@ dfield_set_data( const void* data, /*!< in: data */ ulint len) /*!< in: length or UNIV_SQL_NULL */ { -#ifdef UNIV_VALGRIND_DEBUG - if (len != UNIV_SQL_NULL) UNIV_MEM_ASSERT_RW(data, len); -#endif /* UNIV_VALGRIND_DEBUG */ field->data = (void*) data; field->ext = 0; field->len = static_cast<unsigned int>(len); @@ -111,9 +104,7 @@ dfield_write_mbr( dfield_t* field, /*!< in: field */ const double* mbr) /*!< in: data */ { -#ifdef UNIV_VALGRIND_DEBUG - if (len != UNIV_SQL_NULL) UNIV_MEM_ASSERT_RW(data, len); -#endif /* UNIV_VALGRIND_DEBUG */ + MEM_CHECK_DEFINED(mbr, sizeof *mbr); field->ext = 0; for (unsigned i = 0; i < SPDIMS * 2; i++) { @@ -175,7 +166,7 @@ dfield_dup( mem_heap_t* heap) /*!< in: memory heap where allocated */ { if (!dfield_is_null(field)) { - UNIV_MEM_ASSERT_RW(field->data, field->len); + MEM_CHECK_DEFINED(field->data, field->len); field->data = mem_heap_dup(heap, field->data, field->len); } } @@ -333,8 +324,9 @@ dtuple_create_from_mem( } } #endif - UNIV_MEM_ASSERT_W(tuple->fields, n_t_fields * sizeof *tuple->fields); - UNIV_MEM_INVALID(tuple->fields, n_t_fields * sizeof *tuple->fields); + MEM_CHECK_ADDRESSABLE(tuple->fields, n_t_fields + * sizeof *tuple->fields); + MEM_UNDEFINED(tuple->fields, n_t_fields * sizeof *tuple->fields); return(tuple); } diff --git a/storage/innobase/include/dict0stats.ic b/storage/innobase/include/dict0stats.ic index 3c24e7a8fc3..dbdbceab9ba 100644 --- a/storage/innobase/include/dict0stats.ic +++ b/storage/innobase/include/dict0stats.ic @@ -187,41 +187,40 @@ dict_stats_deinit( table->stat_initialized = FALSE; -#ifdef UNIV_DEBUG_VALGRIND - UNIV_MEM_INVALID(&table->stat_n_rows, - sizeof(table->stat_n_rows)); - UNIV_MEM_INVALID(&table->stat_clustered_index_size, - sizeof(table->stat_clustered_index_size)); - UNIV_MEM_INVALID(&table->stat_sum_of_other_index_sizes, - sizeof(table->stat_sum_of_other_index_sizes)); - UNIV_MEM_INVALID(&table->stat_modified_counter, - sizeof(table->stat_modified_counter)); +#ifdef HAVE_valgrind_or_MSAN + MEM_UNDEFINED(&table->stat_n_rows, sizeof table->stat_n_rows); + MEM_UNDEFINED(&table->stat_clustered_index_size, + sizeof table->stat_clustered_index_size); + MEM_UNDEFINED(&table->stat_sum_of_other_index_sizes, + sizeof table->stat_sum_of_other_index_sizes); + MEM_UNDEFINED(&table->stat_modified_counter, + sizeof table->stat_modified_counter); dict_index_t* index; for (index = dict_table_get_first_index(table); index != NULL; index = dict_table_get_next_index(index)) { - UNIV_MEM_INVALID( + MEM_UNDEFINED( index->stat_n_diff_key_vals, index->n_uniq - * sizeof(index->stat_n_diff_key_vals[0])); - UNIV_MEM_INVALID( + * sizeof index->stat_n_diff_key_vals[0]); + MEM_UNDEFINED( index->stat_n_sample_sizes, index->n_uniq - * sizeof(index->stat_n_sample_sizes[0])); - UNIV_MEM_INVALID( + * sizeof index->stat_n_sample_sizes[0]); + MEM_UNDEFINED( index->stat_n_non_null_key_vals, index->n_uniq - * sizeof(index->stat_n_non_null_key_vals[0])); - UNIV_MEM_INVALID( + * sizeof index->stat_n_non_null_key_vals[0]); + MEM_UNDEFINED( &index->stat_index_size, sizeof(index->stat_index_size)); - UNIV_MEM_INVALID( + MEM_UNDEFINED( &index->stat_n_leaf_pages, sizeof(index->stat_n_leaf_pages)); } -#endif /* UNIV_DEBUG_VALGRIND */ +#endif /* HAVE_valgrind_or_MSAN */ rw_lock_x_unlock(&table->stats_latch); } diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 0f3a568a048..9e0cab12373 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -24,8 +24,7 @@ Full text search header file Created 2011/09/02 Sunny Bains ***********************************************************************/ -#ifndef fts0fts_h -#define fts0fts_h +#pragma once #include "data0type.h" #include "data0types.h" @@ -986,8 +985,12 @@ fts_trx_t* fts_trx_create( trx_t* trx); +/** Clear all fts resources when there is no internal DOC_ID +and there are no new fts index to add. +@param[in,out] table table where fts is to be freed +@param[in] trx transaction to drop all fts tables */ +void fts_clear_all(dict_table_t *table, trx_t *trx); + /** Sync the table during commit phase @param[in] table table to be synced */ void fts_sync_during_ddl(dict_table_t* table); - -#endif /*!< fts0fts.h */ diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index 2a88c0f1065..c1e7348a548 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -203,7 +203,7 @@ mem_heap_alloc( mem_block_set_free(block, free + MEM_SPACE_NEEDED(n)); buf = buf + REDZONE_SIZE; - UNIV_MEM_ALLOC(buf, n - REDZONE_SIZE); + MEM_UNDEFINED(buf, n - REDZONE_SIZE); return(buf); } @@ -268,7 +268,7 @@ mem_heap_free_heap_top( ulint(old_top - reinterpret_cast<byte*>(block))); ut_ad(mem_block_get_start(block) <= mem_block_get_free(block)); - UNIV_MEM_FREE(old_top, (byte*) block + block->len - old_top); + MEM_NOACCESS(old_top, (byte*) block + block->len - old_top); /* If free == start, we may free the block if it is not the first one */ @@ -342,7 +342,7 @@ mem_heap_free_top( == mem_block_get_start(block))) { mem_heap_block_free(heap, block); } else { - UNIV_MEM_FREE((byte*) block + mem_block_get_free(block), n); + MEM_NOACCESS((byte*) block + mem_block_get_free(block), n); } } diff --git a/storage/innobase/include/page0zip.ic b/storage/innobase/include/page0zip.ic index a59d880284a..ede61283f33 100644 --- a/storage/innobase/include/page0zip.ic +++ b/storage/innobase/include/page0zip.ic @@ -218,7 +218,7 @@ page_zip_get_trailer_len( ulint uncompressed_size; ut_ad(page_zip_simple_validate(page_zip)); - UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); + MEM_CHECK_DEFINED(page_zip->data, page_zip_get_size(page_zip)); if (!page_is_leaf(page_zip->data)) { uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE diff --git a/storage/innobase/include/read0types.h b/storage/innobase/include/read0types.h index ff282aa1f3f..dc0ffffda1f 100644 --- a/storage/innobase/include/read0types.h +++ b/storage/innobase/include/read0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, MariaDB Corporation. +Copyright (c) 2018, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -290,7 +290,7 @@ public: MEM_UNDEFINED(&m_mutex, sizeof m_mutex); #endif #ifdef HAVE_valgrind - UNIV_MEM_VALID(&m_mutex, sizeof m_mutex); + MEM_MAKE_VALID(&m_mutex, sizeof m_mutex); #endif } }; diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h index 197375b6301..c51e831fb0e 100644 --- a/storage/innobase/include/rem0rec.h +++ b/storage/innobase/include/rem0rec.h @@ -601,19 +601,17 @@ rec_offs_make_nth_extern( rec_offs* offsets, const ulint n); +MY_ATTRIBUTE((nonnull)) /** Determine the number of allocated elements for an array of offsets. @param[in] offsets offsets after rec_offs_set_n_alloc() @return number of elements */ -inline -ulint -rec_offs_get_n_alloc(const rec_offs* offsets) +inline ulint rec_offs_get_n_alloc(const rec_offs *offsets) { - ulint n_alloc; - ut_ad(offsets); - n_alloc = offsets[0]; - ut_ad(n_alloc > REC_OFFS_HEADER_SIZE); - UNIV_MEM_ASSERT_W(offsets, n_alloc * sizeof *offsets); - return(n_alloc); + ut_ad(offsets); + ulint n_alloc= offsets[0]; + ut_ad(n_alloc > REC_OFFS_HEADER_SIZE); + MEM_CHECK_ADDRESSABLE(offsets, n_alloc * sizeof *offsets); + return n_alloc; } /** Determine the number of fields for which offsets have been initialized. diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic index 6d0a1771f6d..30c72a7415a 100644 --- a/storage/innobase/include/rem0rec.ic +++ b/storage/innobase/include/rem0rec.ic @@ -703,7 +703,7 @@ rec_offs_set_n_alloc( ulint n_alloc) /*!< in: number of elements */ { ut_ad(n_alloc > REC_OFFS_HEADER_SIZE); - UNIV_MEM_ALLOC(offsets, n_alloc * sizeof *offsets); + MEM_UNDEFINED(offsets, n_alloc * sizeof *offsets); offsets[0] = static_cast<rec_offs>(n_alloc); } diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 8f497fa9f44..8e833642ee0 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -2,7 +2,7 @@ Copyright (c) 2010, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2019, MariaDB Corporation. +Copyright (c) 2013, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -651,14 +651,14 @@ Use MONITOR_DEC if appropriate mutex protection exists. } \ } -#ifdef UNIV_DEBUG_VALGRIND +#ifdef HAVE_valgrind_or_MSAN # define MONITOR_CHECK_DEFINED(value) do { \ mon_type_t m = value; \ - UNIV_MEM_ASSERT_RW(&m, sizeof m); \ + MEM_CHECK_DEFINED(&m, sizeof m); \ } while (0) -#else /* UNIV_DEBUG_VALGRIND */ +#else /* HAVE_valgrind_or_MSAN */ # define MONITOR_CHECK_DEFINED(value) (void) 0 -#endif /* UNIV_DEBUG_VALGRIND */ +#endif /* HAVE_valgrind_or_MSAN */ #define MONITOR_INC_VALUE(monitor, value) \ MONITOR_CHECK_DEFINED(value); \ diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 147a6285e5c..18c228e56c3 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -170,14 +170,6 @@ using the call command. */ #define UNIV_ENABLE_UNIT_TEST_ROW_RAW_FORMAT_INT */ -#include <my_valgrind.h> - -#if defined HAVE_valgrind && defined HAVE_VALGRIND_MEMCHECK_H -# define UNIV_DEBUG_VALGRIND -#elif __has_feature(memory_sanitizer) -# define UNIV_DEBUG_VALGRIND -#endif - #ifdef DBUG_OFF # undef UNIV_DEBUG #elif !defined UNIV_DEBUG @@ -185,8 +177,6 @@ using the call command. */ #endif #if 0 -#define UNIV_DEBUG_VALGRIND /* Enable extra - Valgrind instrumentation */ #define UNIV_DEBUG_PRINT /* Enable the compilation of some debug print functions */ #define UNIV_AHI_DEBUG /* Enable adaptive hash index @@ -575,56 +565,6 @@ typedef void* os_thread_ret_t; #include "ut0ut.h" #include "sync0types.h" -/* define UNIV macros in terms of my_valgrind.h */ -#define UNIV_MEM_INVALID(addr, size) MEM_UNDEFINED(addr, size) -#define UNIV_MEM_FREE(addr, size) MEM_NOACCESS(addr, size) -#define UNIV_MEM_ALLOC(addr, size) UNIV_MEM_INVALID(addr, size) -#ifdef UNIV_DEBUG_VALGRIND -# include <valgrind/memcheck.h> -# define UNIV_MEM_VALID(addr, size) MEM_MAKE_DEFINED(addr, size) -# define UNIV_MEM_DESC(addr, size) VALGRIND_CREATE_BLOCK(addr, size, #addr) -# define UNIV_MEM_UNDESC(b) VALGRIND_DISCARD(b) -# define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do { \ - const void* _p = (const void*) (ulint) \ - VALGRIND_CHECK_MEM_IS_DEFINED(addr, size); \ - if (UNIV_LIKELY_NULL(_p)) { \ - fprintf(stderr, "%s:%d: %p[%u] undefined at %ld\n", \ - __FILE__, __LINE__, \ - (const void*) (addr), (unsigned) (size), (long) \ - (((const char*) _p) - ((const char*) (addr)))); \ - if (should_abort) { \ - ut_error; \ - } \ - } \ -} while (0) -# define UNIV_MEM_ASSERT_RW(addr, size) \ - UNIV_MEM_ASSERT_RW_LOW(addr, size, false) -# define UNIV_MEM_ASSERT_RW_ABORT(addr, size) \ - UNIV_MEM_ASSERT_RW_LOW(addr, size, true) -# define UNIV_MEM_ASSERT_W(addr, size) do { \ - const void* _p = (const void*) (ulint) \ - VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, size); \ - if (UNIV_LIKELY_NULL(_p)) \ - fprintf(stderr, "%s:%d: %p[%u] unwritable at %ld\n", \ - __FILE__, __LINE__, \ - (const void*) (addr), (unsigned) (size), (long) \ - (((const char*) _p) - ((const char*) (addr)))); \ - } while (0) -# define UNIV_MEM_TRASH(addr, c, size) do { \ - ut_d(memset(addr, c, size)); \ - UNIV_MEM_INVALID(addr, size); \ - } while (0) -#else -# define UNIV_MEM_VALID(addr, size) do {} while(0) -# define UNIV_MEM_DESC(addr, size) do {} while(0) -# define UNIV_MEM_UNDESC(b) do {} while(0) -# define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do {} while(0) -# define UNIV_MEM_ASSERT_RW(addr, size) do {} while(0) -# define UNIV_MEM_ASSERT_RW_ABORT(addr, size) do {} while(0) -# define UNIV_MEM_ASSERT_W(addr, size) do {} while(0) -# define UNIV_MEM_TRASH(addr, c, size) do {} while(0) -#endif - extern ulong srv_page_size_shift; extern ulong srv_page_size; diff --git a/storage/innobase/include/ut0pool.h b/storage/innobase/include/ut0pool.h index f6006144dc4..703a07a23f2 100644 --- a/storage/innobase/include/ut0pool.h +++ b/storage/innobase/include/ut0pool.h @@ -94,7 +94,7 @@ struct Pool { #ifdef HAVE_valgrind /* Declare the contents as initialized for Valgrind; we checked this in mem_free(). */ - UNIV_MEM_VALID(&elem->m_type, sizeof elem->m_type); + MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type); #endif Factory::destroy(&elem->m_type); } @@ -137,13 +137,12 @@ struct Pool { MEM_UNDEFINED(&elem->m_type, sizeof elem->m_type); # endif # ifdef HAVE_valgrind - /* Declare the memory initialized for Valgrind. The trx_t that are released to the pool are actually initialized; we checked that by - UNIV_MEM_ASSERT_RW() in mem_free() below. */ - UNIV_MEM_VALID(&elem->m_type, sizeof elem->m_type); + MEM_CHECK_DEFINED() in mem_free() below. */ # endif + MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type); } #endif @@ -159,7 +158,7 @@ struct Pool { byte* p = reinterpret_cast<byte*>(ptr + 1); elem = reinterpret_cast<Element*>(p - sizeof(*elem)); - UNIV_MEM_ASSERT_RW(&elem->m_type, sizeof elem->m_type); + MEM_CHECK_DEFINED(&elem->m_type, sizeof elem->m_type); elem->m_pool->m_lock_strategy.enter(); |