From 466bc8f7e08cecb1a4f137439824e4f0136a4cdf Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Apr 2024 17:22:11 +0200 Subject: [PATCH 1/4] fix failing large_tests.maria_recover_encrypted update results --- mysql-test/suite/large_tests/r/maria_recover_encrypted.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/large_tests/r/maria_recover_encrypted.result b/mysql-test/suite/large_tests/r/maria_recover_encrypted.result index a7293d45db6..fb7f1ef1c2f 100644 --- a/mysql-test/suite/large_tests/r/maria_recover_encrypted.result +++ b/mysql-test/suite/large_tests/r/maria_recover_encrypted.result @@ -36,7 +36,7 @@ CALL proc_insert_many(); UNLOCK TABLES; SET debug_dbug="d,crash_shutdown"; shutdown; -ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to server during query SELECT * FROM t1 ORDER BY 1 DESC LIMIT 10; field1 field2 field3 1069999 2069999 3069999 From fbfb5a6f59ccf6cefffc373e3a5776d49604c64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 18 Apr 2024 15:41:30 +0300 Subject: [PATCH 2/4] MDEV-33928 : Assertion failure on wsrep_thd_is_aborting Problem was assertion assuming we always hold THD::LOCK_thd_data mutex that is not true. In most cases this is true but function is also used from InnoDB lock manager and there we can't take THD::LOCK_thd_data to obey mutex ordering. Removed assertion as wsrep transaction state can't change even that case. Signed-off-by: Julius Goryavsky --- sql/service_wsrep.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sql/service_wsrep.cc b/sql/service_wsrep.cc index 06513387ac7..f8c6ddaa28b 100644 --- a/sql/service_wsrep.cc +++ b/sql/service_wsrep.cc @@ -1,4 +1,4 @@ -/* Copyright 2018-2023 Codership Oy +/* Copyright 2018-2024 Codership Oy 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 @@ -263,12 +263,28 @@ extern "C" my_bool wsrep_thd_order_before(const THD *left, const THD *right) return FALSE; } +/** Check if wsrep transaction is aborting state. + +Calling function should make sure that wsrep transaction state +can't change during this function. + +This function is called from +wsrep_abort_thd where we hold THD::LOCK_thd_data +wsrep_handle_mdl_conflict we hold THD::LOCK_thd_data +wsrep_assert_no_bf_bf_wait we hold lock_sys.latch +innobase_kill_query we hold THD::LOCK_thd_data (THD::awake_no_mutex) + +@param thd thread handle + +@return true if wsrep transaction is aborting +@return false if not + +*/ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd) { - mysql_mutex_assert_owner(&thd->LOCK_thd_data); - const wsrep::client_state& cs(thd->wsrep_cs()); const enum wsrep::transaction::state tx_state(cs.transaction().state()); + switch (tx_state) { case wsrep::transaction::s_must_abort: @@ -277,7 +293,7 @@ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd) case wsrep::transaction::s_aborting: return true; default: - return false; + break; } return false; From 07faba08b9e12eeaf35c4afdd99bd2d87a32c02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 23 Apr 2024 12:57:39 +0300 Subject: [PATCH 3/4] MDEV-27924 fixup: cmake -DWITH_INNODB_EXTRA_DEBUG=ON --- storage/innobase/page/page0zip.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 36624f43d10..7c10255c7a0 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -3270,7 +3270,6 @@ page_zip_validate_low( ibool sloppy) /*!< in: FALSE=strict, TRUE=ignore the MIN_REC_FLAG */ { - page_zip_des_t temp_page_zip; ibool valid; if (memcmp(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV, @@ -3311,7 +3310,7 @@ page_zip_validate_low( MEM_CHECK_DEFINED(page, srv_page_size); MEM_CHECK_DEFINED(page_zip->data, page_zip_get_size(page_zip)); - temp_page_zip = *page_zip; + page_zip_des_t temp_page_zip(*page_zip); valid = page_zip_decompress_low(&temp_page_zip, temp_page, TRUE); if (!valid) { fputs("page_zip_validate(): failed to decompress\n", stderr); From 0ccdf54b644352f42e1768bc660be7ab50c1e9d2 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 19 Apr 2024 13:10:58 +0300 Subject: [PATCH 4/4] Check and remove high stack usage I checked all stack overflow potential problems found with gcc -Wstack-usage=16384 and clang -Wframe-larger-than=16384 -no-inline Fixes: Added '#pragma clang diagnostic ignored "-Wframe-larger-than="' to a lot of function to where stack usage large but resonable. - Added stack check warnings to BUILD scrips when using clang and debug. Function changed to use malloc instead allocating things on stack: - read_bootstrap_query() now allocates line_buffer (20000 bytes) with malloc() instead of using stack. This has a small performance impact but this is not releant for bootstrap. - mroonga grn_select() used 65856 bytes on stack. Changed it to use malloc(). - Wsrep_schema::replay_transaction() and Wsrep_schema::recover_sr_transactions(). - Connect zipOpen3() Not fixed: - mroonga/vendor/groonga/lib/expr.c grn_proc_call() uses 43712 byte on stack. However this is not easy to fix as the stack used is caused by a lot of code generated by defines. - Most changes in mroonga/groonga where only adding of pragmas to disable stack warnings. - rocksdb/options/options_helper.cc uses 20288 of stack space. (no reason to fix except to get rid of the compiler warning) - Causes using alloca() where the allocation size is resonable. - An issue in libmariadb (reported to connectors). --- BUILD/SETUP.sh | 6 ++ client/mysqlcheck.c | 7 +- client/mysqlslap.c | 4 + client/mysqltest.cc | 2 +- extra/mariabackup/fil_cur.cc | 4 + include/my_attribute.h | 14 +++ sql/sql_bootstrap.cc | 31 ++++-- sql/sql_statistics.cc | 12 +++ sql/sql_yacc.yy | 3 + sql/wsrep_schema.cc | 99 +++++++++++-------- storage/archive/ha_archive.cc | 18 ++++ storage/connect/ha_connect.cc | 9 ++ storage/connect/tabmul.cpp | 6 +- storage/connect/zip.c | 58 +++++------ storage/innobase/row/row0quiesce.cc | 5 + storage/maria/ma_loghandler.c | 4 + storage/maria/ma_open.c | 4 + storage/maria/ma_recovery.c | 34 ++++--- storage/maria/unittest/ma_test_loghandler-t.c | 3 + storage/mroonga/vendor/groonga/CMakeLists.txt | 1 + storage/mroonga/vendor/groonga/lib/db.c | 18 +++- storage/mroonga/vendor/groonga/lib/load.c | 5 + storage/mroonga/vendor/groonga/lib/operator.c | 5 + .../groonga/lib/proc/proc_object_list.c | 4 + .../vendor/groonga/lib/proc/proc_schema.c | 9 +- .../vendor/groonga/lib/proc/proc_select.c | 20 ++-- storage/perfschema/unittest/pfs_instr-t.cc | 3 + storage/spider/spd_db_conn.cc | 4 + tests/async_queries.c | 2 + tests/mysql_client_fw.c | 4 + unittest/mysys/bitmap-t.c | 4 + unittest/sql/mf_iocache-t.cc | 3 + 32 files changed, 296 insertions(+), 109 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index cab2c0d5f3d..b62497333c3 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -267,6 +267,12 @@ if test `$CC -v 2>&1 | tail -1 | sed 's/ .*$//'` = 'gcc' ; then fi fi +if test `$CC -v 2>&1 | head -1 | sed 's/ .*$//'` = 'clang' ; then + dbug_cflags="$dbug_cflags -Wframe-larger-than=16384 -fno-inline" + c_warnings="$c_warnings -Wframe-larger-than=16384" + cxx_warnings="$cxx_warnings -Wframe-larger-than=16384" +fi + # If ccache (a compiler cache which reduces build time) # (http://samba.org/ccache) is installed, use it. diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index e5f5700ecfd..25c2f795665 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -896,6 +896,7 @@ static int disable_binlog() return run_query("SET SQL_LOG_BIN=0", 0); } + static int handle_request_for_tables(char *tables, size_t length, my_bool view, my_bool dont_quote) { @@ -1027,7 +1028,10 @@ static void insert_table_name(DYNAMIC_ARRAY *arr, char *in, size_t dblen) insert_dynamic(arr, (uchar*) buf); } -static void print_result() +/* Ok as mysqlcheck is not multi threaded */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + +static void __attribute__((noinline)) print_result() { MYSQL_RES *res; MYSQL_ROW row; @@ -1118,6 +1122,7 @@ static void print_result() mysql_free_result(res); DBUG_VOID_RETURN; } +PRAGMA_REENABLE_CHECK_STACK_FRAME static int dbConnect(char *host, char *user, char *passwd) diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 885a5f43e35..ea821242733 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1649,6 +1649,9 @@ drop_primary_key_list(void) return 0; } + +PRAGMA_DISABLE_CHECK_STACK_FRAME + static int create_schema(MYSQL *mysql, const char *db, statement *stmt, option_string *engine_stmt) @@ -1744,6 +1747,7 @@ limit_not_met: DBUG_RETURN(0); } +PRAGMA_REENABLE_CHECK_STACK_FRAME static int drop_schema(MYSQL *mysql, const char *db) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index e0a0cd219c7..ff7e974ee9b 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -78,7 +78,7 @@ static my_bool non_blocking_api_enabled= 0; #define MAX_DELIMITER_LENGTH 16 #define DEFAULT_MAX_CONN 64 -#define DIE_BUFF_SIZE 256*1024 +#define DIE_BUFF_SIZE 15*1024 #define RESULT_STRING_INIT_MEM 2048 #define RESULT_STRING_INCREMENT_MEM 2048 diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index ca64c1c53f6..6f31583072b 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -244,6 +244,9 @@ xb_fil_cur_open( return(XB_FIL_CUR_SUCCESS); } +/* Stack usage 131224 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static bool page_is_corrupted(const byte *page, ulint page_no, const xb_fil_cur_t *cursor, const fil_space_t *space) @@ -347,6 +350,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no, return buf_page_is_corrupted(true, page, space->flags); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** Reads and verifies the next block of pages from the source file. Positions the cursor after the last read non-corrupted page. diff --git a/include/my_attribute.h b/include/my_attribute.h index c8e980702b6..25d21d5e787 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -70,5 +70,19 @@ # endif /* GNUC >= 3.1 */ #endif +/* Define pragmas to disable warnings for stack frame checking */ +#if defined(__clang__) +#define PRAGMA_DISABLE_CHECK_STACK_FRAME \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wframe-larger-than=\"") + +#define PRAGMA_REENABLE_CHECK_STACK_FRAME \ +_Pragma("clang diagnostic pop") + +#else +#define PRAGMA_DISABLE_CHECK_STACK_FRAME +#define PRAGMA_REENABLE_CHECK_STACK_FRAME #endif + +#endif /* _my_attribute_h */ diff --git a/sql/sql_bootstrap.cc b/sql/sql_bootstrap.cc index b39d7a57bc0..72821384bb6 100644 --- a/sql/sql_bootstrap.cc +++ b/sql/sql_bootstrap.cc @@ -33,26 +33,35 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, fgets_input_t input, fgets_fn_t fgets_fn, int preserve_delimiter, int *error) { - char line_buffer[MAX_BOOTSTRAP_LINE_SIZE]; + char *line_buffer; const char *line; size_t len; size_t query_len= 0; int fgets_error= 0; + int exit_code= 0; *error= 0; + line_buffer= (char*) malloc(MAX_BOOTSTRAP_LINE_SIZE); + *query_length= 0; for ( ; ; ) { - line= (*fgets_fn)(line_buffer, sizeof(line_buffer), input, &fgets_error); + line= (*fgets_fn)(line_buffer, MAX_BOOTSTRAP_LINE_SIZE, input, &fgets_error); if (error) *error= fgets_error; if (fgets_error != 0) - return READ_BOOTSTRAP_ERROR; + { + exit_code= READ_BOOTSTRAP_ERROR; + break; + } if (line == NULL) - return (query_len == 0) ? READ_BOOTSTRAP_EOF : READ_BOOTSTRAP_ERROR; + { + exit_code= (query_len == 0) ? READ_BOOTSTRAP_EOF : READ_BOOTSTRAP_ERROR; + break; + } len= strlen(line); @@ -98,7 +107,8 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, if (!p || !p[1]) { /* Invalid DELIMITER specifier */ - return READ_BOOTSTRAP_ERROR; + exit_code= READ_BOOTSTRAP_ERROR; + break; } delimiter.assign(p+1); if (preserve_delimiter) @@ -106,7 +116,8 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, memcpy(query,line,len); query[len]=0; *query_length = (int)len; - return READ_BOOTSTRAP_SUCCESS; + exit_code= READ_BOOTSTRAP_SUCCESS; + break; } continue; } @@ -125,7 +136,8 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, } query[query_len]= '\0'; *query_length= (int)query_len; - return READ_BOOTSTRAP_QUERY_SIZE; + exit_code= READ_BOOTSTRAP_QUERY_SIZE; + break; } if (query_len != 0) @@ -152,8 +164,11 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, } query[query_len]= 0; *query_length= (int)query_len; - return READ_BOOTSTRAP_SUCCESS; + exit_code= READ_BOOTSTRAP_SUCCESS; + break; } } + free(line_buffer); + return exit_code; } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 32fe80c9a9f..3f4f5745565 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2786,6 +2786,9 @@ int collect_statistics_for_table(THD *thd, TABLE *table) After having been updated the statistical system tables are closed. */ +/* Stack usage 20248 from clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int update_statistics_for_table(THD *thd, TABLE *table) { TABLE_LIST tables[STATISTICS_TABLES]; @@ -2870,6 +2873,7 @@ int update_statistics_for_table(THD *thd, TABLE *table) new_trans.restore_old_transaction(); DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** @@ -3282,6 +3286,9 @@ end: The function is called when executing the statement DROP TABLE 'tab'. */ +/* Stack size 20248 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int delete_statistics_for_table(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *tab) { @@ -3350,6 +3357,7 @@ int delete_statistics_for_table(THD *thd, const LEX_CSTRING *db, new_trans.restore_old_transaction(); DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** @@ -3894,6 +3902,9 @@ int rename_indexes_in_stat_table(THD *thd, TABLE *tab, The function is called when executing any statement that renames a table */ +/* Stack size 20968 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *tab, const LEX_CSTRING *new_db, @@ -3971,6 +3982,7 @@ int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, new_trans.restore_old_transaction(); DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a4e3a4c6531..023af109a3f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -80,6 +80,9 @@ #pragma GCC diagnostic ignored "-Wunused-label" /* yyexhaustedlab: */ #endif +/* Stack size 28200 with clang for MYSQLparse() and ORAparse() */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int yylex(void *yylval, void *yythd); #define yyoverflow(A,B,C,D,E,F) \ diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index 4ad829c14a6..2473d20b20d 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -1252,15 +1252,21 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, DBUG_ENTER("Wsrep_schema::replay_transaction"); DBUG_ASSERT(!fragments.empty()); - THD thd(next_thread_id(), true); - thd.thread_stack= (orig_thd ? orig_thd->thread_stack : - (char*) &thd); - wsrep_assign_from_threadvars(&thd); + THD *thd= new THD(next_thread_id(), true); + if (!thd) + { + WSREP_WARN("Could not open allocate memory for THD"); + DBUG_RETURN(1); + } - Wsrep_schema_impl::wsrep_off wsrep_off(&thd); - Wsrep_schema_impl::binlog_off binlog_off(&thd); - Wsrep_schema_impl::sql_safe_updates sql_safe_updates(&thd); - Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd, &thd); + thd->thread_stack= (orig_thd ? orig_thd->thread_stack : + (char*) &thd); + wsrep_assign_from_threadvars(thd); + + Wsrep_schema_impl::wsrep_off wsrep_off(thd); + Wsrep_schema_impl::binlog_off binlog_off(thd); + Wsrep_schema_impl::sql_safe_updates sql_safe_updates(thd); + Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd, thd); int ret= 1; int error; @@ -1272,11 +1278,12 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, for (std::vector::const_iterator i= fragments.begin(); i != fragments.end(); ++i) { - Wsrep_schema_impl::init_stmt(&thd); - if ((error= Wsrep_schema_impl::open_for_read(&thd, sr_table_str.c_str(), &frag_table_l))) + Wsrep_schema_impl::init_stmt(thd); + if ((error= Wsrep_schema_impl::open_for_read(thd, sr_table_str.c_str(), &frag_table_l))) { WSREP_WARN("Could not open SR table for read: %d", error); - Wsrep_schema_impl::finish_stmt(&thd); + Wsrep_schema_impl::finish_stmt(thd); + my_free(thd); DBUG_RETURN(1); } frag_table= frag_table_l.table; @@ -1308,7 +1315,7 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, frag_table->field[4]->val_str(&buf); { - Wsrep_schema_impl::thd_context_switch thd_context_switch(&thd, orig_thd); + Wsrep_schema_impl::thd_context_switch thd_context_switch(thd, orig_thd); ret= wsrep_apply_events(orig_thd, rli, buf.ptr(), buf.length()); if (ret) @@ -1319,17 +1326,18 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, } Wsrep_schema_impl::end_index_scan(frag_table); - Wsrep_schema_impl::finish_stmt(&thd); + Wsrep_schema_impl::finish_stmt(thd); - Wsrep_schema_impl::init_stmt(&thd); + Wsrep_schema_impl::init_stmt(thd); - if ((error= Wsrep_schema_impl::open_for_write(&thd, + if ((error= Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table_l))) { WSREP_WARN("Could not open SR table for write: %d", error); - Wsrep_schema_impl::finish_stmt(&thd); - DBUG_RETURN(1); + Wsrep_schema_impl::finish_stmt(thd); + ret= 1; + break; } frag_table= frag_table_l.table; @@ -1355,60 +1363,68 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, break; } Wsrep_schema_impl::end_index_scan(frag_table); - Wsrep_schema_impl::finish_stmt(&thd); + Wsrep_schema_impl::finish_stmt(thd); my_free(key); key= NULL; } if (key) my_free(key); + delete thd; DBUG_RETURN(ret); } + int Wsrep_schema::recover_sr_transactions(THD *orig_thd) { DBUG_ENTER("Wsrep_schema::recover_sr_transactions"); - THD storage_thd(next_thread_id(), true); - storage_thd.thread_stack= (orig_thd ? orig_thd->thread_stack : + + THD *storage_thd= new THD(next_thread_id(), true); + if (!storage_thd) + { + WSREP_WARN("Could not open allocate memory for THD"); + DBUG_RETURN(1); + } + storage_thd->thread_stack= (orig_thd ? orig_thd->thread_stack : (char*) &storage_thd); - wsrep_assign_from_threadvars(&storage_thd); + wsrep_assign_from_threadvars(storage_thd); TABLE* frag_table= 0; TABLE_LIST frag_table_l; TABLE* cluster_table= 0; TABLE_LIST cluster_table_l; - Wsrep_storage_service storage_service(&storage_thd); - Wsrep_schema_impl::binlog_off binlog_off(&storage_thd); - Wsrep_schema_impl::wsrep_off wsrep_off(&storage_thd); - Wsrep_schema_impl::sql_safe_updates sql_safe_updates(&storage_thd); + Wsrep_storage_service storage_service(storage_thd); + Wsrep_schema_impl::binlog_off binlog_off(storage_thd); + Wsrep_schema_impl::wsrep_off wsrep_off(storage_thd); + Wsrep_schema_impl::sql_safe_updates sql_safe_updates(storage_thd); Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd, - &storage_thd); + storage_thd); Wsrep_server_state& server_state(Wsrep_server_state::instance()); int ret= 1; int error; wsrep::id cluster_id; - Wsrep_schema_impl::init_stmt(&storage_thd); - storage_thd.wsrep_skip_locking= FALSE; - if (Wsrep_schema_impl::open_for_read(&storage_thd, cluster_table_str.c_str(), + Wsrep_schema_impl::init_stmt(storage_thd); + storage_thd->wsrep_skip_locking= FALSE; + if (Wsrep_schema_impl::open_for_read(storage_thd, cluster_table_str.c_str(), &cluster_table_l)) { - Wsrep_schema_impl::finish_stmt(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); DBUG_RETURN(1); } cluster_table= cluster_table_l.table; if (Wsrep_schema_impl::init_for_scan(cluster_table)) { - Wsrep_schema_impl::finish_stmt(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); DBUG_RETURN(1); } if ((error= Wsrep_schema_impl::next_record(cluster_table))) { Wsrep_schema_impl::end_scan(cluster_table); - Wsrep_schema_impl::finish_stmt(&storage_thd); - trans_commit(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); + trans_commit(storage_thd); if (error == HA_ERR_END_OF_FILE) { WSREP_INFO("Cluster table is empty, not recovering transactions"); @@ -1423,20 +1439,20 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) Wsrep_schema_impl::scan(cluster_table, 0, cluster_id); Wsrep_schema_impl::end_scan(cluster_table); - Wsrep_schema_impl::finish_stmt(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); std::ostringstream os; os << cluster_id; WSREP_INFO("Recovered cluster id %s", os.str().c_str()); - storage_thd.wsrep_skip_locking= TRUE; - Wsrep_schema_impl::init_stmt(&storage_thd); + storage_thd->wsrep_skip_locking= TRUE; + Wsrep_schema_impl::init_stmt(storage_thd); /* Open the table for reading and writing so that fragments without valid seqno can be deleted. */ - if (Wsrep_schema_impl::open_for_write(&storage_thd, sr_table_str.c_str(), + if (Wsrep_schema_impl::open_for_write(storage_thd, sr_table_str.c_str(), &frag_table_l)) { WSREP_ERROR("Failed to open SR table for write"); @@ -1492,7 +1508,7 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) transaction_id))) { DBUG_ASSERT(wsrep::starts_transaction(flags)); - applier = wsrep_create_streaming_applier(&storage_thd, "recovery"); + applier = wsrep_create_streaming_applier(storage_thd, "recovery"); server_state.start_streaming_applier(server_id, transaction_id, applier); applier->start_transaction(wsrep::ws_handle(transaction_id, 0), @@ -1520,9 +1536,10 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) } } Wsrep_schema_impl::end_scan(frag_table); - Wsrep_schema_impl::finish_stmt(&storage_thd); - trans_commit(&storage_thd); - storage_thd.set_mysys_var(0); + Wsrep_schema_impl::finish_stmt(storage_thd); + trans_commit(storage_thd); + storage_thd->set_mysys_var(0); out: + delete storage_thd; DBUG_RETURN(ret); } diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 2df54567285..2d623507fd3 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -267,6 +267,9 @@ ha_archive::ha_archive(handlerton *hton, TABLE_SHARE *table_arg) archive_reader_open= FALSE; } +/* Stack size 50264 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int archive_discover(handlerton *hton, THD* thd, TABLE_SHARE *share) { DBUG_ENTER("archive_discover"); @@ -308,6 +311,7 @@ ret: my_free(frm_ptr); DBUG_RETURN(my_errno); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** @brief Read version 1 meta file (5.0 compatibility routine). @@ -478,6 +482,10 @@ int ha_archive::read_data_header(azio_stream *file_to_read) See ha_example.cc for a longer description. */ + +/* Stack size 49608 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + Archive_share *ha_archive::get_share(const char *table_name, int *rc) { Archive_share *tmp_share; @@ -540,6 +548,7 @@ err: DBUG_RETURN(tmp_share); } +PRAGMA_REENABLE_CHECK_STACK_FRAME int Archive_share::init_archive_writer() @@ -761,6 +770,9 @@ int ha_archive::frm_compare(azio_stream *s) of creation. */ +/* Stack size 49608 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int ha_archive::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { @@ -876,6 +888,7 @@ error: /* Return error number, if we got one */ DBUG_RETURN(error ? error : -1); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* This is where the actual row is written out. @@ -1494,6 +1507,10 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) The table can become fragmented if data was inserted, read, and then inserted again. What we do is open up the file and recompress it completely. */ + +/* Stack size 50152 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) { int rc= 0; @@ -1619,6 +1636,7 @@ error: DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* Below is an example of how to setup row level locking. diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 253c8e8e305..d2d667d1382 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -6448,6 +6448,9 @@ char *ha_connect::GetDBfromName(const char *name) ha_create_table() in handle.cc */ +/* Stack size 25608 in clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int ha_connect::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { @@ -6989,6 +6992,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, table= st; DBUG_RETURN(rc); } // end of create +PRAGMA_REENABLE_CHECK_STACK_FRAME /** Used to check whether a file based outward table can be populated by @@ -6996,6 +7000,10 @@ int ha_connect::create(const char *name, TABLE *table_arg, - file does not exist or is void - user has file privilege */ + +/* Stack size 16664 in clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + bool ha_connect::FileExists(const char *fn, bool bf) { if (!fn || !*fn) @@ -7046,6 +7054,7 @@ bool ha_connect::FileExists(const char *fn, bool bf) return true; } // end of FileExists +PRAGMA_REENABLE_CHECK_STACK_FRAME // Called by SameString and NoFieldOptionChange bool ha_connect::CheckString(PCSZ str1, PCSZ str2) diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 4fad2b27cd8..d3f86e9cfb1 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -125,8 +125,11 @@ PTDB TDBMUL::Duplicate(PGLOBAL g) /* have a LRECL that is the sum of the lengths of all components. */ /* This is why we use a big filename array to take care of that. */ /***********************************************************************/ + +PRAGMA_DISABLE_CHECK_STACK_FRAME + bool TDBMUL::InitFileNames(PGLOBAL g) - { +{ #define PFNZ 4096 #define FNSZ (_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT) PTDBDIR dirp; @@ -241,6 +244,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) NumFiles = n; return false; } // end of InitFileNames +PRAGMA_REENABLE_CHECK_STACK_FRAME /***********************************************************************/ /* The table column list is the sub-table column list. */ diff --git a/storage/connect/zip.c b/storage/connect/zip.c index 3d3d4caddef..458446c96b1 100644 --- a/storage/connect/zip.c +++ b/storage/connect/zip.c @@ -814,71 +814,66 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { /************************************************************/ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) { - zip64_internal ziinit; zip64_internal* zi; int err=ZIP_OK; - ziinit.z_filefunc.zseek32_file = NULL; - ziinit.z_filefunc.ztell32_file = NULL; - if (pzlib_filefunc64_32_def==NULL) - fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); - else - ziinit.z_filefunc = *pzlib_filefunc64_32_def; + if (!(zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)))) + return NULL; - ziinit.filestream = ZOPEN64(ziinit.z_filefunc, + zi->z_filefunc.zseek32_file = NULL; + zi->z_filefunc.ztell32_file = NULL; + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&zi->z_filefunc.zfile_func64); + else + zi->z_filefunc = *pzlib_filefunc64_32_def; + + zi->filestream = ZOPEN64(zi->z_filefunc, pathname, (append == APPEND_STATUS_CREATE) ? (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); - if (ziinit.filestream == NULL) - return NULL; - - if (append == APPEND_STATUS_CREATEAFTER) - ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END); - - ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream); - ziinit.in_opened_file_inzip = 0; - ziinit.ci.stream_initialised = 0; - ziinit.number_entry = 0; - ziinit.add_position_when_writing_offset = 0; - init_linkedlist(&(ziinit.central_dir)); - - - - zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)); - if (zi==NULL) + if (zi->filestream == NULL) { - ZCLOSE64(ziinit.z_filefunc,ziinit.filestream); + free(zi); return NULL; } + if (append == APPEND_STATUS_CREATEAFTER) + ZSEEK64(zi->z_filefunc,zi->filestream,0,SEEK_END); + + zi->begin_pos = ZTELL64(zi->z_filefunc,zi->filestream); + zi->in_opened_file_inzip = 0; + zi->ci.stream_initialised = 0; + zi->number_entry = 0; + zi->add_position_when_writing_offset = 0; + init_linkedlist(&(zi->central_dir)); + /* now we add file in a zipfile */ # ifndef NO_ADDFILEINEXISTINGZIP - ziinit.globalcomment = NULL; + zi->globalcomment = NULL; if (append == APPEND_STATUS_ADDINZIP) { // Read and Cache Central Directory Records - err = LoadCentralDirectoryRecord(&ziinit); + err = LoadCentralDirectoryRecord(zi); } if (globalcomment) { - *globalcomment = ziinit.globalcomment; + *globalcomment = zi->globalcomment; } # endif /* !NO_ADDFILEINEXISTINGZIP*/ if (err != ZIP_OK) { # ifndef NO_ADDFILEINEXISTINGZIP - free(ziinit.globalcomment); + free(zi->globalcomment); # endif /* !NO_ADDFILEINEXISTINGZIP*/ free(zi); return NULL; } else { - *zi = ziinit; return (zipFile)zi; } } @@ -1027,7 +1022,6 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c int err = ZIP_OK; # ifdef NOCRYPT - (crcForCrypting); if (password != NULL) return ZIP_PARAMERROR; # endif diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index e927096f296..057b20c77bd 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -431,6 +431,10 @@ row_quiesce_write_header( /*********************************************************************//** Write the table meta data after quiesce. @return DB_SUCCESS or error code */ + +/* Stack size 20904 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_cfg( @@ -488,6 +492,7 @@ row_quiesce_write_cfg( return(err); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /*********************************************************************//** Check whether a table has an FTS index defined on it. diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index ce59f03dd2d..ffbcfecae95 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -3605,6 +3605,9 @@ static my_bool translog_is_LSN_chunk(uchar type) @retval 1 Error */ +/* Stack size 26120 from clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + my_bool translog_init_with_table(const char *directory, uint32 log_file_max_size, uint32 server_version, @@ -4238,6 +4241,7 @@ err: ma_message_no_user(0, "log initialization failed"); DBUG_RETURN(1); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 2497bc41e8f..39a16ea5df4 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -1558,6 +1558,9 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite) @retval 1 Error */ +/* Stack size 26376 from clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite) { uchar buff[MARIA_STATE_INFO_SIZE + MARIA_STATE_EXTRA_SIZE]; @@ -1632,6 +1635,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite) MYF(MY_NABP)); DBUG_RETURN(res != 0); } +PRAGMA_REENABLE_CHECK_STACK_FRAME static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state, myf flag) diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 006c8bef672..df9b2024086 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -1163,11 +1163,12 @@ end: /* The record may come from REPAIR, ALTER TABLE ENABLE KEYS, OPTIMIZE. */ + prototype_redo_exec_hook(REDO_REPAIR_TABLE) { int error= 1; MARIA_HA *info; - HA_CHECK param; + HA_CHECK *param; char *name; my_bool quick_repair; DBUG_ENTER("exec_REDO_LOGREC_REDO_REPAIR_TABLE"); @@ -1199,35 +1200,39 @@ prototype_redo_exec_hook(REDO_REPAIR_TABLE) */ tprint(tracef, " repairing...\n"); - maria_chk_init(¶m); - param.isam_file_name= name= info->s->open_file_name.str; - param.testflag= uint8korr(rec->header + FILEID_STORE_SIZE); - param.tmpdir= maria_tmpdir; - param.max_trid= max_long_trid; + if (!(param= my_malloc(PSI_INSTRUMENT_ME, sizeof(*param), MYF(MY_WME)))) + DBUG_RETURN(0); + + maria_chk_init(param); + param->isam_file_name= name= info->s->open_file_name.str; + param->testflag= uint8korr(rec->header + FILEID_STORE_SIZE); + param->tmpdir= maria_tmpdir; + param->max_trid= max_long_trid; DBUG_ASSERT(maria_tmpdir); info->s->state.key_map= uint8korr(rec->header + FILEID_STORE_SIZE + 8); - quick_repair= MY_TEST(param.testflag & T_QUICK); + quick_repair= MY_TEST(param->testflag & T_QUICK); - if (param.testflag & T_REP_PARALLEL) + if (param->testflag & T_REP_PARALLEL) { - if (maria_repair_parallel(¶m, info, name, quick_repair)) + if (maria_repair_parallel(param, info, name, quick_repair)) goto end; } - else if (param.testflag & T_REP_BY_SORT) + else if (param->testflag & T_REP_BY_SORT) { - if (maria_repair_by_sort(¶m, info, name, quick_repair)) + if (maria_repair_by_sort(param, info, name, quick_repair)) goto end; } - else if (maria_repair(¶m, info, name, quick_repair)) + else if (maria_repair(param, info, name, quick_repair)) goto end; if (_ma_update_state_lsns(info->s, rec->lsn, trnman_get_min_safe_trid(), - TRUE, !(param.testflag & T_NO_CREATE_RENAME_LSN))) + TRUE, !(param->testflag & T_NO_CREATE_RENAME_LSN))) goto end; error= 0; end: + my_free(param); DBUG_RETURN(error); } @@ -2579,6 +2584,8 @@ prototype_undo_exec_hook(UNDO_BULK_INSERT) return error; } +/* Stack size 18776 in clang. Ok as this is during recover */ +PRAGMA_DISABLE_CHECK_STACK_FRAME static int run_redo_phase(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply) { @@ -2822,6 +2829,7 @@ err: translog_free_record_header(&rec); DBUG_RETURN(1); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index ccda66af755..800a315d987 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -143,6 +143,8 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec, } +PRAGMA_DISABLE_CHECK_STACK_FRAME + int main(int argc __attribute__((unused)), char *argv[]) { uint32 i; @@ -664,5 +666,6 @@ err: my_end(0); return(MY_TEST(exit_status())); } +PRAGMA_REENABLE_CHECK_STACK_FRAME #include "../ma_check_standalone.h" diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt index 5b25ada4f5b..cdbfb8f160b 100644 --- a/storage/mroonga/vendor/groonga/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/CMakeLists.txt @@ -200,6 +200,7 @@ endif() include_directories( BEFORE + ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/lib diff --git a/storage/mroonga/vendor/groonga/lib/db.c b/storage/mroonga/vendor/groonga/lib/db.c index c3bbb64f703..65463bdad20 100644 --- a/storage/mroonga/vendor/groonga/lib/db.c +++ b/storage/mroonga/vendor/groonga/lib/db.c @@ -38,6 +38,7 @@ #include "grn_util.h" #include "grn_cache.h" #include "grn_window_functions.h" +#include #include #include @@ -1060,6 +1061,8 @@ grn_table_create_validate(grn_ctx *ctx, const char *name, unsigned int name_size return ctx->rc; } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static grn_obj * grn_table_create_with_max_n_subrecs(grn_ctx *ctx, const char *name, unsigned int name_size, const char *path, @@ -1238,6 +1241,7 @@ grn_table_create_with_max_n_subrecs(grn_ctx *ctx, const char *name, } return res; } +PRAGMA_REENABLE_CHECK_STACK_FRAME grn_obj * grn_table_create(grn_ctx *ctx, const char *name, unsigned int name_size, @@ -4776,6 +4780,9 @@ _grn_table_key(grn_ctx *ctx, grn_obj *table, grn_id id, uint32_t *key_size) /* column */ + +PRAGMA_DISABLE_CHECK_STACK_FRAME + grn_obj * grn_column_create(grn_ctx *ctx, grn_obj *table, const char *name, unsigned int name_size, @@ -4978,6 +4985,7 @@ exit : if (!res && id) { grn_obj_delete_by_id(ctx, db, id, GRN_TRUE); } GRN_API_RETURN(res); } +PRAGMA_REENABLE_CHECK_STACK_FRAME grn_obj * grn_column_open(grn_ctx *ctx, grn_obj *table, @@ -8540,6 +8548,8 @@ grn_obj_spec_save(grn_ctx *ctx, grn_db_obj *obj) grn_obj_close(ctx, &v); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + inline static void grn_obj_set_info_source_invalid_lexicon_error(grn_ctx *ctx, const char *message, @@ -8590,6 +8600,8 @@ grn_obj_set_info_source_invalid_lexicon_error(grn_ctx *ctx, source_name_size, source_name); } +PRAGMA_REENABLE_CHECK_STACK_FRAME + inline static grn_rc grn_obj_set_info_source_validate(grn_ctx *ctx, grn_obj *obj, grn_obj *value) { @@ -8597,7 +8609,7 @@ grn_obj_set_info_source_validate(grn_ctx *ctx, grn_obj *obj, grn_obj *value) grn_obj *lexicon = NULL; grn_id lexicon_domain_id; grn_obj *lexicon_domain = NULL; - grn_bool lexicon_domain_is_table; + grn_bool lexicon_domain_is_table __attribute__((unused)); grn_bool lexicon_have_tokenizer; grn_id *source_ids; int i, n_source_ids; @@ -9330,7 +9342,7 @@ remove_reference_tables(grn_ctx *ctx, grn_obj *table, grn_obj *db) grn_bool is_close_opened_object_mode = GRN_FALSE; grn_id table_id; char table_name[GRN_TABLE_MAX_KEY_SIZE]; - int table_name_size; + int table_name_size __attribute__((unused)); grn_table_cursor *cursor; if (grn_thread_get_limit() == 1) { @@ -10317,12 +10329,10 @@ grn_db_spec_unpack(grn_ctx *ctx, const char *error_message_tag) { grn_obj *db; - grn_db *db_raw; grn_rc rc; uint32_t spec_size; db = ctx->impl->db; - db_raw = (grn_db *)db; rc = grn_vector_decode(ctx, decoded_spec, diff --git a/storage/mroonga/vendor/groonga/lib/load.c b/storage/mroonga/vendor/groonga/lib/load.c index eb77f2b3849..25d621e7f56 100644 --- a/storage/mroonga/vendor/groonga/lib/load.c +++ b/storage/mroonga/vendor/groonga/lib/load.c @@ -20,6 +20,9 @@ #include "grn_ctx_impl.h" #include "grn_db.h" #include "grn_util.h" +#include + +PRAGMA_DISABLE_CHECK_STACK_FRAME static void grn_loader_save_error(grn_ctx *ctx, grn_loader *loader) @@ -1228,3 +1231,5 @@ grn_load(grn_ctx *ctx, grn_content_type input_type, } GRN_API_RETURN(ctx->rc); } + +PRAGMA_REENABLE_CHECK_STACK_FRAME diff --git a/storage/mroonga/vendor/groonga/lib/operator.c b/storage/mroonga/vendor/groonga/lib/operator.c index 1e1f2cf7e4d..940c0b14a09 100644 --- a/storage/mroonga/vendor/groonga/lib/operator.c +++ b/storage/mroonga/vendor/groonga/lib/operator.c @@ -20,6 +20,7 @@ #include "grn_db.h" #include "grn_str.h" #include "grn_normalizer.h" +#include #include @@ -31,6 +32,8 @@ # include #endif +PRAGMA_DISABLE_CHECK_STACK_FRAME + static const char *operator_names[] = { "push", "pop", @@ -1360,3 +1363,5 @@ grn_operator_exec_regexp(grn_ctx *ctx, grn_obj *target, grn_obj *pattern) } GRN_API_RETURN(matched); } + +PRAGMA_REENABLE_CHECK_STACK_FRAME diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c b/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c index adb4c91bc1f..eaf5504d1fa 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c @@ -18,6 +18,7 @@ #include "../grn_proc.h" #include "../grn_db.h" +#include #include @@ -73,6 +74,8 @@ command_object_list_dump_flags(grn_ctx *ctx, grn_obj_spec *spec) GRN_OBJ_FIN(ctx, &flags); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static grn_obj * command_object_list(grn_ctx *ctx, int nargs, @@ -401,6 +404,7 @@ command_object_list(grn_ctx *ctx, return NULL; } +PRAGMA_REENABLE_CHECK_STACK_FRAME void grn_proc_init_object_list(grn_ctx *ctx) diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c b/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c index 061c145a112..7c632f45e53 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c @@ -17,9 +17,8 @@ */ #include "../grn_proc.h" - #include "../grn_db.h" - +#include #include typedef struct { @@ -572,6 +571,8 @@ command_schema_table_output_token_filters(grn_ctx *ctx, grn_obj *table) GRN_OBJ_FIN(ctx, &token_filters); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static void command_schema_table_command_collect_arguments(grn_ctx *ctx, grn_obj *table, @@ -692,6 +693,7 @@ command_schema_table_command_collect_arguments(grn_ctx *ctx, #undef ADD_OBJECT_NAME #undef ADD } +PRAGMA_REENABLE_CHECK_STACK_FRAME static void command_schema_table_output_command(grn_ctx *ctx, grn_obj *table) @@ -875,6 +877,8 @@ command_schema_output_indexes(grn_ctx *ctx, grn_obj *object) } } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static void command_schema_column_command_collect_arguments(grn_ctx *ctx, grn_obj *table, @@ -973,6 +977,7 @@ command_schema_column_command_collect_arguments(grn_ctx *ctx, #undef ADD_OBJECT_NAME #undef ADD } +PRAGMA_REENABLE_CHECK_STACK_FRAME static void command_schema_column_output_command(grn_ctx *ctx, diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_select.c b/storage/mroonga/vendor/groonga/lib/proc/proc_select.c index a665b1cc898..7588b18a17c 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_select.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_select.c @@ -24,6 +24,7 @@ #include "../grn_util.h" #include "../grn_cache.h" #include "../grn_ii.h" +#include #include "../grn_ts.h" @@ -2912,7 +2913,7 @@ grn_select(grn_ctx *ctx, grn_select_data *data) uint32_t nhits; grn_obj *outbuf = ctx->impl->output.buf; grn_content_type output_type = ctx->impl->output.type; - char cache_key[GRN_CACHE_MAX_KEY_SIZE]; + char *cache_key_buffer= 0; uint32_t cache_key_size; long long int threshold, original_threshold = 0; grn_cache *cache_obj = grn_cache_current_get(ctx); @@ -2985,8 +2986,9 @@ grn_select(grn_ctx *ctx, grn_select_data *data) } GRN_HASH_EACH_END(ctx, cursor); } #undef DRILLDOWN_CACHE_SIZE - if (cache_key_size <= GRN_CACHE_MAX_KEY_SIZE) { - char *cp = cache_key; + if (cache_key_size <= GRN_CACHE_MAX_KEY_SIZE && + (cache_key_buffer= (char*) malloc(cache_key_size+1))) { + char *cp = cache_key_buffer; #define PUT_CACHE_KEY(string) \ if ((string).value) \ @@ -3066,11 +3068,12 @@ grn_select(grn_ctx *ctx, grn_select_data *data) { grn_rc rc; - rc = grn_cache_fetch(ctx, cache_obj, cache_key, cache_key_size, outbuf); + rc = grn_cache_fetch(ctx, cache_obj, cache_key_buffer, cache_key_size, outbuf); if (rc == GRN_SUCCESS) { GRN_QUERY_LOG(ctx, GRN_QUERY_LOG_CACHE, ":", "cache(%" GRN_FMT_LLD ")", (long long int)GRN_TEXT_LEN(outbuf)); + free(cache_key_buffer); return ctx->rc; } } @@ -3119,7 +3122,7 @@ grn_select(grn_ctx *ctx, grn_select_data *data) data->cache.length != 2 || data->cache.value[0] != 'n' || data->cache.value[1] != 'o')) { - grn_cache_update(ctx, cache_obj, cache_key, cache_key_size, outbuf); + grn_cache_update(ctx, cache_obj, cache_key_buffer, cache_key_size, outbuf); } goto exit; } @@ -3186,7 +3189,7 @@ grn_select(grn_ctx *ctx, grn_select_data *data) data->cache.length != 2 || data->cache.value[0] != 'n' || data->cache.value[1] != 'o')) { - grn_cache_update(ctx, cache_obj, cache_key, cache_key_size, outbuf); + grn_cache_update(ctx, cache_obj, cache_key_buffer, cache_key_size, outbuf); } if (data->taintable > 0) { grn_db_touch(ctx, DB_OBJ(data->tables.target)->db); @@ -3200,6 +3203,7 @@ exit : /* GRN_LOG(ctx, GRN_LOG_NONE, "%d", ctx->seqno); */ + free(cache_key_buffer); return ctx->rc; } @@ -3424,6 +3428,9 @@ grn_select_data_fill_drilldown_columns(grn_ctx *ctx, strlen(prefix)); } + +PRAGMA_DISABLE_CHECK_STACK_FRAME + static grn_bool grn_select_data_fill_drilldowns(grn_ctx *ctx, grn_user_data *user_data, @@ -3562,6 +3569,7 @@ grn_select_data_fill_drilldowns(grn_ctx *ctx, return succeeded; } } +PRAGMA_REENABLE_CHECK_STACK_FRAME static grn_obj * command_select(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) diff --git a/storage/perfschema/unittest/pfs_instr-t.cc b/storage/perfschema/unittest/pfs_instr-t.cc index 9667d7ff2be..55c4f61997b 100644 --- a/storage/perfschema/unittest/pfs_instr-t.cc +++ b/storage/perfschema/unittest/pfs_instr-t.cc @@ -86,6 +86,8 @@ void test_no_instruments() cleanup_instruments(); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + void test_no_instances() { int rc; @@ -245,6 +247,7 @@ void test_no_instances() cleanup_file_hash(); cleanup_instruments(); } +PRAGMA_REENABLE_CHECK_STACK_FRAME void test_with_instances() { diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 5333b31fcd1..2dc179f4a28 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -11421,6 +11421,9 @@ int spider_db_udf_ping_table_append_select( DBUG_RETURN(0); } +/* Stack size 33032 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int spider_db_udf_ping_table_mon_next( THD *thd, SPIDER_TABLE_MON *table_mon, @@ -11567,6 +11570,7 @@ int spider_db_udf_ping_table_mon_next( delete res; DBUG_RETURN(error_num); } +PRAGMA_REENABLE_CHECK_STACK_FRAME int spider_db_udf_copy_key_row( spider_string *str, diff --git a/tests/async_queries.c b/tests/async_queries.c index 8509b414f6e..f0b4fab870a 100644 --- a/tests/async_queries.c +++ b/tests/async_queries.c @@ -358,6 +358,7 @@ handle_option(const struct my_option *opt, const char *arg, return 0; } +PRAGMA_DISABLE_CHECK_STACK_FRAME int main(int argc, char *argv[]) @@ -433,3 +434,4 @@ main(int argc, char *argv[]) return 0; } +PRAGMA_REENABLE_CHECK_STACK_FRAME diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index c9e64678527..173d8a2ea16 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -568,6 +568,9 @@ static int my_process_result(MYSQL *mysql_arg) #define MAX_RES_FIELDS 50 #define MAX_FIELD_DATA_SIZE 255 +/* Stack usage 18888 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static int my_process_stmt_result(MYSQL_STMT *stmt) { int field_count; @@ -656,6 +659,7 @@ static int my_process_stmt_result(MYSQL_STMT *stmt) mysql_free_result(result); return row_count; } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* Prepare statement, execute, and process result set for given query */ diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c index 3698d76654d..8caab0e408e 100644 --- a/unittest/mysys/bitmap-t.c +++ b/unittest/mysys/bitmap-t.c @@ -123,6 +123,8 @@ error6: return TRUE; } +PRAGMA_DISABLE_CHECK_STACK_FRAME + my_bool test_compare_operators(MY_BITMAP *map, uint bitsize) { uint i, j, test_bit1, test_bit2, test_bit3,test_bit4; @@ -228,6 +230,8 @@ error5: test_bit1); return TRUE; } +PRAGMA_REENABLE_CHECK_STACK_FRAME + my_bool test_count_bits_set(MY_BITMAP *map, uint bitsize) { diff --git a/unittest/sql/mf_iocache-t.cc b/unittest/sql/mf_iocache-t.cc index cc97d3b221a..c72e6b7c7e2 100644 --- a/unittest/sql/mf_iocache-t.cc +++ b/unittest/sql/mf_iocache-t.cc @@ -96,6 +96,8 @@ void sql_print_error(const char *format, ...) /*** end of encryption tweaks and stubs ****************************/ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static IO_CACHE info; #define CACHE_SIZE 16384 @@ -472,3 +474,4 @@ int main(int argc __attribute__((unused)),char *argv[]) return exit_status(); } +PRAGMA_REENABLE_CHECK_STACK_FRAME