Post-review fixes of BUG#9937: Crash on call to stored procedure.
sql/item_cmpfunc.cc: Put the buff parameter back in check_stack_overrun(). sql/item_func.cc: Put the buff parameter back in check_stack_overrun(). sql/item_subselect.cc: Put the buff parameter back in check_stack_overrun(). sql/mysql_priv.h: Put the buff parameter back in check_stack_overrun(). sql/mysqld.cc: Style fixes. sql/sp_head.cc: Put the buff parameter back in check_stack_overrun(). sql/sql_parse.cc: Put the buff parameter back in check_stack_overrun(), and added comment explaining the purpose. sql/table.cc: Put the buff parameter back in check_stack_overrun().
This commit is contained in:
parent
4701bd908b
commit
2e113adab3
@ -2321,7 +2321,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
*/
|
||||
and_tables_cache= ~(table_map) 0;
|
||||
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE))
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
|
||||
return TRUE; // Fatal error flag is set!
|
||||
/*
|
||||
The following optimization reduces the depth of an AND-OR tree.
|
||||
|
@ -293,11 +293,14 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 0);
|
||||
Item **arg,**arg_end;
|
||||
#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
|
||||
char buff[STACK_BUFF_ALLOC]; // Max argument in function
|
||||
#endif
|
||||
|
||||
used_tables_cache= not_null_tables_cache= 0;
|
||||
const_item_cache=1;
|
||||
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE+STACK_BUFF_ALLOC))
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
|
||||
return TRUE; // Fatal error if flag is set!
|
||||
if (arg_count)
|
||||
{ // Print purify happy
|
||||
@ -2564,9 +2567,12 @@ bool
|
||||
udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func,
|
||||
uint arg_count, Item **arguments)
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
|
||||
char buff[STACK_BUFF_ALLOC]; // Max argument in function
|
||||
#endif
|
||||
DBUG_ENTER("Item_udf_func::fix_fields");
|
||||
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE+STACK_BUFF_ALLOC))
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
|
||||
DBUG_RETURN(TRUE); // Fatal error flag is set!
|
||||
|
||||
udf_func *tmp_udf=find_udf(u_d->name.str,(uint) u_d->name.length,1);
|
||||
|
@ -138,7 +138,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref)
|
||||
DBUG_ASSERT(fixed == 0);
|
||||
engine->set_thd((thd= thd_param));
|
||||
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE))
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE, (gptr)&res))
|
||||
return TRUE;
|
||||
|
||||
res= engine->prepare();
|
||||
|
@ -1429,11 +1429,11 @@ inline int hexchar_to_int(char c)
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
extern "C" void unireg_abort(int exit_code);
|
||||
void kill_delayed_threads(void);
|
||||
bool check_stack_overrun(THD *thd, long margin);
|
||||
bool check_stack_overrun(THD *thd, long margin, char *dummy);
|
||||
#else
|
||||
#define unireg_abort(exit_code) DBUG_RETURN(exit_code)
|
||||
inline void kill_delayed_threads(void) {}
|
||||
#define check_stack_overrun(A, B) 0
|
||||
#define check_stack_overrun(A, B, C) 0
|
||||
#endif
|
||||
|
||||
#endif /* MYSQL_CLIENT */
|
||||
|
@ -2091,8 +2091,10 @@ static void start_signal_handler(void)
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&thr_attr,INTERRUPT_PRIOR);
|
||||
#if defined(__ia64__) || defined(__ia64)
|
||||
/* Peculiar things with ia64 platforms - it seems we only have half the
|
||||
stack size in reality, so we have to double it here */
|
||||
/*
|
||||
Peculiar things with ia64 platforms - it seems we only have half the
|
||||
stack size in reality, so we have to double it here
|
||||
*/
|
||||
pthread_attr_setstacksize(&thr_attr,thread_stack*2);
|
||||
#else
|
||||
pthread_attr_setstacksize(&thr_attr,thread_stack);
|
||||
@ -3018,8 +3020,10 @@ int main(int argc, char **argv)
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
|
||||
#if defined(__ia64__) || defined(__ia64)
|
||||
/* Peculiar things with ia64 platforms - it seems we only have half the
|
||||
stack size in reality, so we have to double it here */
|
||||
/*
|
||||
Peculiar things with ia64 platforms - it seems we only have half the
|
||||
stack size in reality, so we have to double it here
|
||||
*/
|
||||
pthread_attr_setstacksize(&connection_attrib,thread_stack*2);
|
||||
#else
|
||||
pthread_attr_setstacksize(&connection_attrib,thread_stack);
|
||||
|
@ -565,7 +565,7 @@ sp_head::execute(THD *thd)
|
||||
String old_packet;
|
||||
|
||||
/* Use some extra margin for possible SP recursion and functions */
|
||||
if (check_stack_overrun(thd, 4*STACK_MIN_SIZE))
|
||||
if (check_stack_overrun(thd, 4*STACK_MIN_SIZE, olddb))
|
||||
{
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
@ -4986,7 +4986,14 @@ long max_stack_used;
|
||||
#endif
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
bool check_stack_overrun(THD *thd, long margin)
|
||||
/*
|
||||
Note: The 'buf' parameter is necessary, even if it is unused here.
|
||||
- fix_fields functions has a "dummy" buffer large enough for the
|
||||
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,
|
||||
char *buf __attribute__((unused)))
|
||||
{
|
||||
long stack_used;
|
||||
if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >=
|
||||
|
@ -1815,7 +1815,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
|
||||
bool res= FALSE;
|
||||
DBUG_ENTER("st_table_list::setup_ancestor");
|
||||
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE))
|
||||
if (check_stack_overrun(thd, STACK_MIN_SIZE, (char *)&res))
|
||||
return TRUE;
|
||||
|
||||
for (tbl= ancestor; tbl; tbl= tbl->next_local)
|
||||
|
Loading…
x
Reference in New Issue
Block a user