From e5d54bc2839865710618e7dd18f8b183ba369446 Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Tue, 14 Jun 2022 13:19:12 +0200 Subject: [PATCH 1/2] Bug #34278103 Compile MySQL with GCC 13 [noclose] Add some missing #includes, notably . Silence a new warning for ndbcluster kernel. /opt/gcc-latest/bin/g++ --version g++ (GCC) 13.0.0 20220605 (experimental) Change-Id: I13cc38babfab98251ff0e8fd7568f9cf0dcbc868 (cherry picked from commit acdcb60c731bfe95be11ac287b764eebc844e86f) --- libbinlogevents/include/gtids/global.h | 3 ++- libbinlogevents/include/gtids/gtidset.h | 1 + .../include/mysql/gcs/gcs_group_management_interface.h | 2 ++ .../libmysqlgcs/include/mysql/gcs/gcs_logging.h | 1 + plugin/x/src/interface/document_id_generator.h | 1 + router/src/harness/include/mysql/harness/tty.h | 1 + router/src/harness/include/mysql/harness/vt100.h | 1 + router/src/http/src/base64.h | 1 + router/src/http/src/kdf_pbkdf2.h | 1 + router/src/metadata_cache/src/group_replication_metadata.h | 1 + router/src/mock_server/src/authentication.h | 1 + sql/dd/impl/sdi.h | 1 + storage/ndb/include/portlib/NdbSleep.h | 4 ++++ storage/ndb/plugin/ndb_sync_excluded_objects_table.cc | 1 + storage/ndb/plugin/ndb_sync_pending_objects_table.cc | 1 + storage/ndb/src/common/util/ndb_zlib.cpp | 1 + storage/ndb/src/kernel/CMakeLists.txt | 1 + storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp | 2 ++ 18 files changed, 24 insertions(+), 1 deletion(-) diff --git a/libbinlogevents/include/gtids/global.h b/libbinlogevents/include/gtids/global.h index 7d388f58e2c..ba75da5e88e 100644 --- a/libbinlogevents/include/gtids/global.h +++ b/libbinlogevents/include/gtids/global.h @@ -23,6 +23,7 @@ #ifndef CS_GTIDS_GLOBALS_INCLUDED #define CS_GTIDS_GLOBALS_INCLUDED +#include #include #include #include "libbinlogevents/include/uuid.h" @@ -34,4 +35,4 @@ typedef binary_log::Uuid Uuid; } // namespace binary_log::gtids -#endif \ No newline at end of file +#endif diff --git a/libbinlogevents/include/gtids/gtidset.h b/libbinlogevents/include/gtids/gtidset.h index d6ca13b031b..ef66c72a857 100644 --- a/libbinlogevents/include/gtids/gtidset.h +++ b/libbinlogevents/include/gtids/gtidset.h @@ -23,6 +23,7 @@ #ifndef BINARY_LOG_GTIDS_GTID_SET_INCLUDED #define BINARY_LOG_GTIDS_GTID_SET_INCLUDED +#include #include #include #include diff --git a/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_group_management_interface.h b/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_group_management_interface.h index 34b6a1cde3e..83551aafc26 100644 --- a/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_group_management_interface.h +++ b/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_group_management_interface.h @@ -26,6 +26,8 @@ #include "plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_member_identifier.h" #include "plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_types.h" +#include + class Gcs_group_management_interface { public: /** diff --git a/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_logging.h b/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_logging.h index fd5f8514cf6..22a1446e787 100644 --- a/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_logging.h +++ b/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_logging.h @@ -24,6 +24,7 @@ #define GCS_LOGGING_INCLUDED #include +#include #include #include "plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_types.h" diff --git a/plugin/x/src/interface/document_id_generator.h b/plugin/x/src/interface/document_id_generator.h index 15ba85bf0da..c6e39abbe3e 100644 --- a/plugin/x/src/interface/document_id_generator.h +++ b/plugin/x/src/interface/document_id_generator.h @@ -25,6 +25,7 @@ #ifndef PLUGIN_X_SRC_INTERFACE_DOCUMENT_ID_GENERATOR_H_ #define PLUGIN_X_SRC_INTERFACE_DOCUMENT_ID_GENERATOR_H_ +#include #include #include diff --git a/router/src/harness/include/mysql/harness/tty.h b/router/src/harness/include/mysql/harness/tty.h index be666f6388b..a528d6306f5 100644 --- a/router/src/harness/include/mysql/harness/tty.h +++ b/router/src/harness/include/mysql/harness/tty.h @@ -27,6 +27,7 @@ #include "harness_export.h" +#include #include #ifdef _WIN32 diff --git a/router/src/harness/include/mysql/harness/vt100.h b/router/src/harness/include/mysql/harness/vt100.h index cd916b33691..3bcc2fb7082 100644 --- a/router/src/harness/include/mysql/harness/vt100.h +++ b/router/src/harness/include/mysql/harness/vt100.h @@ -28,6 +28,7 @@ #include "harness_export.h" #include +#include #include #include diff --git a/router/src/http/src/base64.h b/router/src/http/src/base64.h index df99924f8fc..65cbf2334db 100644 --- a/router/src/http/src/base64.h +++ b/router/src/http/src/base64.h @@ -29,6 +29,7 @@ #include // min #include +#include #include #include #include // index_sequence diff --git a/router/src/http/src/kdf_pbkdf2.h b/router/src/http/src/kdf_pbkdf2.h index c5baf786e7e..373ca6aeb13 100644 --- a/router/src/http/src/kdf_pbkdf2.h +++ b/router/src/http/src/kdf_pbkdf2.h @@ -24,6 +24,7 @@ #ifndef MYSQLROUTER_KDF_PBKDF2_INCLUDED #define MYSQLROUTER_KDF_PBKDF2_INCLUDED +#include #include #include #include diff --git a/router/src/metadata_cache/src/group_replication_metadata.h b/router/src/metadata_cache/src/group_replication_metadata.h index cf07d39f93a..417eb7ebc1f 100644 --- a/router/src/metadata_cache/src/group_replication_metadata.h +++ b/router/src/metadata_cache/src/group_replication_metadata.h @@ -25,6 +25,7 @@ #ifndef GROUP_REPLICATION_METADATA_INCLUDED #define GROUP_REPLICATION_METADATA_INCLUDED +#include #include #include #include diff --git a/router/src/mock_server/src/authentication.h b/router/src/mock_server/src/authentication.h index dc6cd96033e..b1d0921a41a 100644 --- a/router/src/mock_server/src/authentication.h +++ b/router/src/mock_server/src/authentication.h @@ -25,6 +25,7 @@ #ifndef MYSQL_PROTOCOL_AUTHENTICATION_INCLUDED #define MYSQL_PROTOCOL_AUTHENTICATION_INCLUDED +#include #include #include #include diff --git a/sql/dd/impl/sdi.h b/sql/dd/impl/sdi.h index 66514452fa4..ab06fbe438a 100644 --- a/sql/dd/impl/sdi.h +++ b/sql/dd/impl/sdi.h @@ -23,6 +23,7 @@ #ifndef DD__SDI_INCLUDED #define DD__SDI_INCLUDED +#include #include #include "my_compiler.h" #include "sql/dd/sdi_fwd.h" // RJ_Document diff --git a/storage/ndb/include/portlib/NdbSleep.h b/storage/ndb/include/portlib/NdbSleep.h index 22fc401107b..b849b6d12ab 100644 --- a/storage/ndb/include/portlib/NdbSleep.h +++ b/storage/ndb/include/portlib/NdbSleep.h @@ -31,6 +31,10 @@ #include #endif +#if defined(HAVE_NANOSLEEP) +#include +#endif + static inline void NdbSleep_MilliSleep(int milliseconds); static inline diff --git a/storage/ndb/plugin/ndb_sync_excluded_objects_table.cc b/storage/ndb/plugin/ndb_sync_excluded_objects_table.cc index d3304558173..ec96aeb3672 100644 --- a/storage/ndb/plugin/ndb_sync_excluded_objects_table.cc +++ b/storage/ndb/plugin/ndb_sync_excluded_objects_table.cc @@ -24,6 +24,7 @@ #include "storage/ndb/plugin/ndb_sync_excluded_objects_table.h" #include +#include #include // std::strlen // assert diff --git a/storage/ndb/plugin/ndb_sync_pending_objects_table.cc b/storage/ndb/plugin/ndb_sync_pending_objects_table.cc index 02650fbc5d6..926b8c3178f 100644 --- a/storage/ndb/plugin/ndb_sync_pending_objects_table.cc +++ b/storage/ndb/plugin/ndb_sync_pending_objects_table.cc @@ -24,6 +24,7 @@ #include "storage/ndb/plugin/ndb_sync_pending_objects_table.h" #include +#include #include // std::strlen // assert diff --git a/storage/ndb/src/common/util/ndb_zlib.cpp b/storage/ndb/src/common/util/ndb_zlib.cpp index 461f61c269c..777d845fc96 100644 --- a/storage/ndb/src/common/util/ndb_zlib.cpp +++ b/storage/ndb/src/common/util/ndb_zlib.cpp @@ -24,6 +24,7 @@ #include "util/ndb_zlib.h" #include // assert() +#include #include // abort() #include "zlib.h" diff --git a/storage/ndb/src/kernel/CMakeLists.txt b/storage/ndb/src/kernel/CMakeLists.txt index e443cbb445e..35d2629ea86 100644 --- a/storage/ndb/src/kernel/CMakeLists.txt +++ b/storage/ndb/src/kernel/CMakeLists.txt @@ -37,6 +37,7 @@ FOREACH(warning "class-memaccess" "format-overflow" "maybe-uninitialized" + "uninitialized" # RedoPageCache CTOR: m_hash(m_pool) with gcc 13 "stringop-overflow" "unused-but-set-variable" "unused-parameter" diff --git a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index 93d60f9aa13..c2e02b19efc 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -2021,6 +2021,8 @@ void Ndbfs::callFSWRITEREQ(BlockReference ref, FsReadWriteReq* req) const Uint32 block = refToMain(ref); Uint32 instance = refToInstance(ref); + ndbrequire(block <= MAX_BLOCK_NO); + SimulatedBlock* main_block = globalData.getBlock(block); ndbrequire(main_block != nullptr); ndbrequire(instance < NDBMT_MAX_BLOCK_INSTANCES); From a283899399647ba1855c84327fd6b2cfaa1381e4 Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Tue, 17 Jan 2023 12:25:10 +0100 Subject: [PATCH 2/2] Bug#34278103 Compile MySQL with GCC 13 [noclose] The newest gcc is stricter about allocator rebind types we got a static_assert: allocator_traits::rebind_alloc must be A Fixed by having a static MEM_ROOT for allocator unit tests, and adding rebind::other for allocator wrapper classes. Change-Id: Ia3b9c29ab2dd371ba97807565dc5c3c174bb4520 (cherry picked from commit 516905d02e829d88ae068d4245c98ed5a8f8e28e) (cherry picked from commit c249973a46ab97b693ef95ad208bc686e001e0df) --- unittest/gunit/stl_alloc-t.cc | 43 +++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/unittest/gunit/stl_alloc-t.cc b/unittest/gunit/stl_alloc-t.cc index 08316235409..c5e54d4c0cd 100644 --- a/unittest/gunit/stl_alloc-t.cc +++ b/unittest/gunit/stl_alloc-t.cc @@ -53,20 +53,43 @@ namespace stlalloc_unittest { These wrappers need to inherit so that they are allocators themselves. Otherwise TypeParam in the tests below will be wrong. */ -template -class Malloc_allocator_wrapper : public Malloc_allocator { +template > +class Malloc_allocator_wrapper : public A { + using a_t = std::allocator_traits; + public: + template + struct rebind { + using other = + Malloc_allocator_wrapper>; + }; + + // Inherit CTORs from base class. + using A::A; + Malloc_allocator_wrapper() : Malloc_allocator(PSI_NOT_INSTRUMENTED) {} }; -template -class Mem_root_allocator_wrapper : public Mem_root_allocator { - MEM_ROOT m_mem_root{PSI_NOT_INSTRUMENTED, 1024}; +// Use a static mem-root for everything, so that list::splice will work. +static MEM_ROOT static_mem_root{PSI_NOT_INSTRUMENTED, 1024}; + +template > +class Mem_root_allocator_wrapper : public A { + using a_t = std::allocator_traits; public: - Mem_root_allocator_wrapper() : Mem_root_allocator(&m_mem_root) { + template + struct rebind { + using other = + Mem_root_allocator_wrapper>; + }; + + // Inherit CTORs from base class. + using A::A; + + Mem_root_allocator_wrapper() : Mem_root_allocator(&static_mem_root) { // memory allocation error is expected, don't abort unit test. - m_mem_root.set_error_handler(nullptr); + static_mem_root.set_error_handler(nullptr); } /* @@ -79,9 +102,9 @@ class Mem_root_allocator_wrapper : public Mem_root_allocator { even with -std=c++17 */ Mem_root_allocator_wrapper(const Mem_root_allocator_wrapper &other) - : Mem_root_allocator(&m_mem_root) { - memcpy(&m_mem_root, &other.m_mem_root, sizeof(m_mem_root)); - } + : Mem_root_allocator(other.m_mem_root_ptr) {} + + MEM_ROOT *m_mem_root_ptr = &static_mem_root; }; /*