From 08fa65fa9c56d81d8fbdfa1eead466a9997e9600 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 7 Jun 2019 11:41:18 +0200 Subject: MDEV-19709 Bitmap<128>::merge etc may crash on older GCC versions Older GCC generates SSE instruction on not-128-bit-aligned data in Bitmap<128>::buffer Workaround by forcing GCC not to use SSE on Bitmap template. --- sql/sql_bitmap.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index 93c5056a8fb..4f1acb60161 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -27,6 +27,18 @@ #include #include +/* + Workaround GCC optimizer bug (generating SSE instuctions on unaligned data) +*/ +#if defined (__GNUC__) && defined(__x86_64__) && (__GNUC__ < 6) +#define NEED_GCC_NO_SSE_WORKAROUND +#endif + +#ifdef NEED_GCC_NO_SSE_WORKAROUND +#pragma GCC push_options +#pragma GCC target ("no-sse") +#endif + template class Bitmap { uint32 buffer[(width + 31) / 32]; @@ -266,6 +278,11 @@ public: }; }; +#ifdef NEED_GCC_NO_SSE_WORKAROUND +#pragma GCC pop_options +#undef NEED_GCC_NO_SSE_WORKAROUND +#endif + /* An iterator to quickly walk over bits in ulonglong bitmap. */ class Table_map_iterator { -- cgit v1.2.1