diff options
author | Martin Liska <mliska@suse.cz> | 2019-12-08 10:52:27 +0100 |
---|---|---|
committer | Anel <an3l@users.noreply.github.com> | 2020-02-08 05:50:01 +0100 |
commit | 35c277851972267d4d020126ab8f893c4b17dd36 (patch) | |
tree | 282fdef16cb18e73c2708a8bff8f04f664012175 /sql/sql_parse.cc | |
parent | 0d1ca1938318d6723c8799e195940c181eec07c2 (diff) | |
download | mariadb-git-35c277851972267d4d020126ab8f893c4b17dd36.tar.gz |
MDEV-21248: Prevent optimizing out buf argument in check_stack_overrun.
When using LTO, one can see optimization of stack variables that
are passed to check_stack_overrun as argument buf. That prevents
proper stack overrun detection.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index dc81e8a2b91..6f3c076709a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7392,8 +7392,17 @@ long max_stack_used; corresponding exec. (Thus we only have to check in fix_fields.) - Passing to check_stack_overrun() prevents the compiler from removing it. */ -bool check_stack_overrun(THD *thd, long margin, - uchar *buf __attribute__((unused))) + +bool +#ifdef __GNUC__ +/* + Do not optimize the function in order to preserve a stack variable creation. + Otherwise, the variable pointed as "buf" can be removed due to a missing + usage. + */ +__attribute__((optimize("-O0"))) +#endif +check_stack_overrun(THD *thd, long margin, uchar *buf __attribute__((unused))) { long stack_used; DBUG_ASSERT(thd == current_thd); |