mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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).
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user