diff options
author | unknown <pem@mysql.comhem.se> | 2005-05-26 20:36:14 +0200 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2005-05-26 20:36:14 +0200 |
commit | 0d8dce039bce76d83702ab5b773ca67120a042e1 (patch) | |
tree | d587d8f1ffd34c519fc63b4b8419ded62ae0a7a3 /sql/mysqld.cc | |
parent | d4be3ae2a3ae1e89756763655044d41bd702cd44 (diff) | |
download | mariadb-git-0d8dce039bce76d83702ab5b773ca67120a042e1.tar.gz |
Fixed BUG#9937: Crash on call to stored procedure.
This only showed up on two known platforms, both ia64 (one HP-UX and one Linux wich icc).
For some reason, they only get half the stack size they are supposed to have, which
makes deep SP recursion overrun the stack before check_stack_overrun() is triggered.
Also made som minor fixes in the check_stack_overrun() definition, supporting variable
margins.
No test case added, but the reason for the bug report was a failed existing test case
on these machines, which now works.
sql/item_cmpfunc.cc:
Adopted call to new check_stack_overrun() definition.
sql/item_func.cc:
Adopted calls to new check_stack_overrun() definition.
sql/item_subselect.cc:
Adopted call to new check_stack_overrun() definition.
sql/mysql_priv.h:
Changed definition of check_stack_overrun(), thread_stack_min variable no longer needed.
sql/mysqld.cc:
thread_stack_min variable no longer needed (with variable margin arg. to check_thread_overrun()).
On (at least some) ia64 machines, it seems we only get half the requested stack in reality,
so deep SP recursion crashes before the thread overrun check is triggered.
We work around this by requesting twice the stack requested to get expected size.
sql/sp_head.cc:
Adopted call to new check_stack_overrun() definition, and use a wider margin
execution.
sql/sql_parse.cc:
Modified check_stack_overrun() definition. Removed unused arg that didn't sever any
purpose, and added a 'margin' argument to support different margins for different
callrers.
sql/table.cc:
Adopted call to new check_stack_overrun() definition.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8c5ce22f7a6..ef8a80a1d1c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -348,7 +348,7 @@ uint tc_heuristic_recover= 0; uint volatile thread_count, thread_running; ulong back_log, connect_timeout, concurrency; ulong server_id, thd_startup_options; -ulong table_cache_size, thread_stack, thread_stack_min, what_to_log; +ulong table_cache_size, thread_stack, what_to_log; ulong query_buff_size, slow_launch_time, slave_open_temp_tables; ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong slave_net_timeout, slave_trans_retries; @@ -2090,8 +2090,14 @@ static void start_signal_handler(void) (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); 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 */ + pthread_attr_setstacksize(&thr_attr,thread_stack*2); +#else pthread_attr_setstacksize(&thr_attr,thread_stack); #endif +#endif (void) pthread_mutex_lock(&LOCK_thread_count); if ((error=pthread_create(&signal_thread,&thr_attr,signal_hand,0))) @@ -3011,23 +3017,35 @@ int main(int argc, char **argv) init_signals(); 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 */ + pthread_attr_setstacksize(&connection_attrib,thread_stack*2); +#else pthread_attr_setstacksize(&connection_attrib,thread_stack); +#endif #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE { /* Retrieve used stack size; Needed for checking stack overflows */ size_t stack_size= 0; pthread_attr_getstacksize(&connection_attrib, &stack_size); +#if defined(__ia64__) || defined(__ia64) + stack_size/= 2; +#endif /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ if (stack_size && stack_size < thread_stack) { if (global_system_variables.log_warnings) sql_print_warning("Asked for %ld thread stack, but got %ld", - thread_stack, stack_size); + thread_stack, stack_size); +#if defined(__ia64__) || defined(__ia64) + thread_stack= stack_size*2; +#else thread_stack= stack_size; +#endif } } #endif - thread_stack_min=thread_stack - STACK_MIN_SIZE; (void) thr_setconcurrency(concurrency); // 10 by default |