From 74f76a439a8d4b59bde88c100dffa0fb0a9b31b8 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 10 Jul 2009 16:00:17 +0300 Subject: [PATCH 1/5] fixed the CPU checking code. --- BUILD/check-cpu | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/BUILD/check-cpu b/BUILD/check-cpu index 4974d3f4ecc..e7cae1c1da8 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -44,8 +44,13 @@ check_cpu () { model_name=`sysctl -n hw.model` ;; Darwin) - cpu_family=`uname -p` - model_name=`machine` + cpu_family=`sysctl -n machdep.cpu.vendor` + model_name=`sysctl -n machdep.cpu.brand_string` + if [ -z "$cpu_family" -o -z "$model_name" ] + then + cpu_family=`uname -p` + model_name=`machine` + fi ;; *) cpu_family=`uname -m`; From 5a6809590c02a0bf851c8e6b89fd3fcabfecbca1 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 10 Jul 2009 15:00:34 +0300 Subject: [PATCH 2/5] Bug #46080: group_concat(... order by) crashes server when sort_buffer_size cannot allocate The NULL return from tree_insert() (on low memory) was not checked for in Item_func_group_concat::add(). As a result on low memory conditions a crash happens. Fixed by properly checking the return code. --- mysql-test/r/bug46080.result | 14 ++++++++++++++ mysql-test/t/bug46080-master.opt | 1 + mysql-test/t/bug46080.test | 19 +++++++++++++++++++ sql/item_sum.cc | 5 +++++ 4 files changed, 39 insertions(+) create mode 100644 mysql-test/r/bug46080.result create mode 100644 mysql-test/t/bug46080-master.opt create mode 100644 mysql-test/t/bug46080.test diff --git a/mysql-test/r/bug46080.result b/mysql-test/r/bug46080.result new file mode 100644 index 00000000000..9ae4b55d8ea --- /dev/null +++ b/mysql-test/r/bug46080.result @@ -0,0 +1,14 @@ +# +# Bug #46080: group_concat(... order by) crashes server when +# sort_buffer_size cannot allocate +# +CREATE TABLE t1(a CHAR(255)); +INSERT INTO t1 VALUES ('a'); +SET @@SESSION.sort_buffer_size=5*16*1000000; +SET @@SESSION.max_heap_table_size=5*1000000; +# Must not crash. +SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a +DROP TABLE t1; +SET @@SESSION.sort_buffer_size=default; +SET @@SESSION.max_heap_table_size=default; +End of 5.0 tests diff --git a/mysql-test/t/bug46080-master.opt b/mysql-test/t/bug46080-master.opt new file mode 100644 index 00000000000..f59740afe60 --- /dev/null +++ b/mysql-test/t/bug46080-master.opt @@ -0,0 +1 @@ +--skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=4000000 diff --git a/mysql-test/t/bug46080.test b/mysql-test/t/bug46080.test new file mode 100644 index 00000000000..9e6cc69b958 --- /dev/null +++ b/mysql-test/t/bug46080.test @@ -0,0 +1,19 @@ +--echo # +--echo # Bug #46080: group_concat(... order by) crashes server when +--echo # sort_buffer_size cannot allocate +--echo # + +CREATE TABLE t1(a CHAR(255)); +INSERT INTO t1 VALUES ('a'); + +SET @@SESSION.sort_buffer_size=5*16*1000000; +SET @@SESSION.max_heap_table_size=5*1000000; + +echo # Must not crash. +SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a; + +DROP TABLE t1; +SET @@SESSION.sort_buffer_size=default; +SET @@SESSION.max_heap_table_size=default; + +--echo End of 5.0 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a381361e8a2..dde8fe29e5a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3291,8 +3291,13 @@ bool Item_func_group_concat::add() TREE_ELEMENT *el= 0; // Only for safety if (row_eligible && tree) + { el= tree_insert(tree, table->record[0] + table->s->null_bytes, 0, tree->custom_arg); + /* check if there was enough memory to insert the row */ + if (!el) + return 1; + } /* If the row is not a duplicate (el->count == 1) we can dump the row here in case of GROUP_CONCAT(DISTINCT...) From 6a7240b8d71e8c003bb88b4f6afafdac820fb819 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 10 Jul 2009 17:03:09 +0300 Subject: [PATCH 3/5] Addendum to the fix for bug #46080: fixed the test case --- mysql-test/r/bug46080.result | 3 ++- mysql-test/t/bug46080.test | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/bug46080.result b/mysql-test/r/bug46080.result index 9ae4b55d8ea..f69c4ac1f71 100644 --- a/mysql-test/r/bug46080.result +++ b/mysql-test/r/bug46080.result @@ -7,7 +7,8 @@ INSERT INTO t1 VALUES ('a'); SET @@SESSION.sort_buffer_size=5*16*1000000; SET @@SESSION.max_heap_table_size=5*1000000; # Must not crash. -SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a +SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a; +Got one of the listed errors DROP TABLE t1; SET @@SESSION.sort_buffer_size=default; SET @@SESSION.max_heap_table_size=default; diff --git a/mysql-test/t/bug46080.test b/mysql-test/t/bug46080.test index 9e6cc69b958..277d513f3e5 100644 --- a/mysql-test/t/bug46080.test +++ b/mysql-test/t/bug46080.test @@ -9,7 +9,8 @@ INSERT INTO t1 VALUES ('a'); SET @@SESSION.sort_buffer_size=5*16*1000000; SET @@SESSION.max_heap_table_size=5*1000000; -echo # Must not crash. +--echo # Must not crash. +--error 5,0 SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a; DROP TABLE t1; From dccac4ff113a1709a9755da4da51880b4a8a8996 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 13 Jul 2009 14:17:14 +0300 Subject: [PATCH 4/5] Addendum to the fix for bug #46080: fixed the error handling --- mysql-test/r/bug46080.result | 1 - mysql-test/t/bug46080.test | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/bug46080.result b/mysql-test/r/bug46080.result index f69c4ac1f71..18c7c22829a 100644 --- a/mysql-test/r/bug46080.result +++ b/mysql-test/r/bug46080.result @@ -8,7 +8,6 @@ SET @@SESSION.sort_buffer_size=5*16*1000000; SET @@SESSION.max_heap_table_size=5*1000000; # Must not crash. SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a; -Got one of the listed errors DROP TABLE t1; SET @@SESSION.sort_buffer_size=default; SET @@SESSION.max_heap_table_size=default; diff --git a/mysql-test/t/bug46080.test b/mysql-test/t/bug46080.test index 277d513f3e5..7e56e3ce421 100644 --- a/mysql-test/t/bug46080.test +++ b/mysql-test/t/bug46080.test @@ -10,8 +10,10 @@ SET @@SESSION.sort_buffer_size=5*16*1000000; SET @@SESSION.max_heap_table_size=5*1000000; --echo # Must not crash. ---error 5,0 +--disable_result_log +--error 0,5 SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a; +--enable_result_log DROP TABLE t1; SET @@SESSION.sort_buffer_size=default; From 47d1a69af8a38df177dec8d4693346935f50e219 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 13 Jul 2009 20:39:58 +0300 Subject: [PATCH 5/5] tree name changed --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 557df1b1ffe..f79c1cd6319 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-5.0-bugteam" +tree_name = "mysql-5.0"