95 lines
3.3 KiB
Diff
95 lines
3.3 KiB
Diff
|
mysql is not accounting for the "guard page" when setting thread stack size
|
||
|
requests. This is fatal on PPC systems, which may use guard pages as large
|
||
|
as 64K. I'll bet a good deal that the hacks it uses for IA64 are a result
|
||
|
of misdiagnosis of a similar problem, so remove them.
|
||
|
|
||
|
It is not at this point entirely clear whether mysql is wrong in ignoring
|
||
|
the guard page, or whether this is a RHEL bug (see our bz#435337). So not
|
||
|
reporting this upstream yet. But we need the patch now, so we can build mysql
|
||
|
in rawhide (the build machines are using RHEL5 kernels).
|
||
|
|
||
|
|
||
|
diff -Naur mysql-5.0.45.orig/sql/mysqld.cc mysql-5.0.45/sql/mysqld.cc
|
||
|
--- mysql-5.0.45.orig/sql/mysqld.cc 2007-07-04 09:06:03.000000000 -0400
|
||
|
+++ mysql-5.0.45/sql/mysqld.cc 2008-02-28 15:17:20.000000000 -0500
|
||
|
@@ -2286,6 +2286,7 @@
|
||
|
{
|
||
|
int error;
|
||
|
pthread_attr_t thr_attr;
|
||
|
+ size_t guard_size = 0;
|
||
|
DBUG_ENTER("start_signal_handler");
|
||
|
|
||
|
(void) pthread_attr_init(&thr_attr);
|
||
|
@@ -2294,15 +2295,9 @@
|
||
|
(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
|
||
|
+
|
||
|
+ pthread_attr_getguardsize(&thr_attr, &guard_size);
|
||
|
+ pthread_attr_setstacksize(&thr_attr, thread_stack + guard_size);
|
||
|
#endif
|
||
|
|
||
|
(void) pthread_mutex_lock(&LOCK_thread_count);
|
||
|
@@ -3499,37 +3494,29 @@
|
||
|
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
|
||
|
+
|
||
|
{
|
||
|
+ size_t guard_size = 0;
|
||
|
+ size_t stack_size = 0;
|
||
|
+
|
||
|
+ pthread_attr_getguardsize(&connection_attrib, &guard_size);
|
||
|
+
|
||
|
+ pthread_attr_setstacksize(&connection_attrib, thread_stack + guard_size);
|
||
|
+
|
||
|
+#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 (stack_size && stack_size < thread_stack + guard_size)
|
||
|
{
|
||
|
if (global_system_variables.log_warnings)
|
||
|
- sql_print_warning("Asked for %lu thread stack, but got %ld",
|
||
|
- thread_stack, (long) stack_size);
|
||
|
-#if defined(__ia64__) || defined(__ia64)
|
||
|
- thread_stack= stack_size*2;
|
||
|
-#else
|
||
|
- thread_stack= stack_size;
|
||
|
-#endif
|
||
|
+ sql_print_warning("Asked for %lu+%lu thread stack, but got %ld",
|
||
|
+ thread_stack, (long) guard_size, (long) stack_size);
|
||
|
+ thread_stack= stack_size - guard_size;
|
||
|
}
|
||
|
- }
|
||
|
#endif
|
||
|
+ }
|
||
|
+
|
||
|
#ifdef __NETWARE__
|
||
|
/* Increasing stacksize of threads on NetWare */
|
||
|
|