From cb253b8687092960287c333962d56771f6ad9db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 30 Oct 2020 13:07:42 +0200 Subject: [PATCH 1/3] MDEV-22387: Static_binary_string::q_append() invokes memcpy on NULL Invoking memcpy() on a NULL pointer is undefined behaviour (even if the length is 0) and gives the compiler permission to assume that the pointer is nonnull. Recent versions of GCC (starting with version 8) are more aggressively optimizing away checks for NULL pointers. This undefined behaviour would cause a SIGSEGV in the test main.func_encrypt on an optimized debug build on GCC 10.2.0. --- sql/sql_string.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_string.h b/sql/sql_string.h index 85c3bbd6044..0098ad15cb6 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -313,7 +313,8 @@ public: } void q_append(const char *data, size_t data_len) { - memcpy(Ptr + str_length, data, data_len); + if (data_len) + memcpy(Ptr + str_length, data, data_len); DBUG_ASSERT(str_length <= UINT_MAX32 - data_len); str_length += (uint)data_len; } From 5b3be9e1c657c3e44377d3c236ff2c31a04adeee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 30 Oct 2020 13:18:41 +0200 Subject: [PATCH 2/3] Try to stabilize main.innodb_ext_key,off Thanks to Varun Gupta for suggesting this. This seems to make main.innodb_ext_key,off more stable. --- mysql-test/main/innodb_ext_key,off.rdiff | 2 ++ mysql-test/main/innodb_ext_key.result | 6 +++--- mysql-test/main/innodb_ext_key.test | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index 2164c56c5b5..f4eaa4b112c 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -1,3 +1,5 @@ +--- innodb_ext_key.result ++++ innodb_ext_key,off.result @@ -9,7 +9,7 @@ explain select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index dbc201be669..7cc03bee546 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -26,12 +26,12 @@ Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 explain -select count(*) from lineitem +select count(*) from lineitem use index(primary) where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem const PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 8 const,const 1 +1 SIMPLE lineitem const PRIMARY PRIMARY 8 const,const 1 flush status; -select count(*) from lineitem +select count(*) from lineitem use index(primary) where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01'; count(*) 1 diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test index 9ca9bbd608f..413d5570be5 100644 --- a/mysql-test/main/innodb_ext_key.test +++ b/mysql-test/main/innodb_ext_key.test @@ -17,6 +17,7 @@ use dbt3_s001; --disable_result_log --disable_warnings --source include/dbt3_s001.inc +ANALYZE TABLE lineitem PERSISTENT FOR COLUMNS() INDEXES(); --enable_warnings --enable_result_log --enable_query_log @@ -28,10 +29,10 @@ select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; show status like 'handler_read%'; explain -select count(*) from lineitem +select count(*) from lineitem use index(primary) where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01'; flush status; -select count(*) from lineitem +select count(*) from lineitem use index(primary) where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01'; show status like 'handler_read%'; From 1fddccf676e213f94923f5efaaa76d9793b19a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 30 Oct 2020 13:26:58 +0200 Subject: [PATCH 3/3] Update Connector/C --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 0cdc1656a70..62427520a5b 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 0cdc1656a70c52103b4329debf9ed02ccacfb3c2 +Subproject commit 62427520a5ba20e42fe51f5045062a7a9cadb466