Hi Dmitry,
On 1/18/11 5:17 AM, Dmitry Shulga wrote:
> #At file:///Users/shulga/projects/mysql/5.1-bugteam-bug58026/ based on
> revid:davi.arnaut@stripped
>
> 3514 Dmitry Shulga 2011-01-18
> Fixed bug#58026 - massive recursion and crash in regular expression
> handling.
>
> The problem was that parsing of nested regular expression involved
> recursive calls. Such recursion didn't take into account the amount of
> available stack space, which ended up leading to stack overflow crashes.
Not approved, some comments below.
[..]
> === modified file 'sql/item_cmpfunc.cc'
> --- a/sql/item_cmpfunc.cc 2010-09-09 12:48:06 +0000
> +++ b/sql/item_cmpfunc.cc 2011-01-18 07:17:19 +0000
> @@ -4791,6 +4791,18 @@ void Item_func_like::cleanup()
>
> #ifdef USE_REGEX
>
> +extern "C"
> +int
> +check_enough_stack_size()
> +{
> +#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
> + uchar stack_top;
> +#endif
> + return check_stack_overrun(current_thd, STACK_MIN_SIZE,
> +&stack_top);
This won't compile when merged to 5.5 and up. Remember to remove the
ifndef when merging.
> +}
> +
> +
> /**
> @brief Compile regular expression.
>
> @@ -4834,7 +4846,8 @@ int Item_func_regex::regcomp(bool send_e
> }
>
> if ((error= my_regcomp(&preg, res->c_ptr_safe(),
> - regex_lib_flags, regex_lib_charset)))
> + regex_lib_flags, regex_lib_charset,
> + check_enough_stack_size)))
This hook initialization should be done through my_regex_init as it is
always constant and applies globally.
Regards,
Davi