Merge lp:~alien-d/maria/mariadb-al13n-bug_886368 into lp:maria/5.5

Proposed by Maarten Vanraes
Status: Needs review
Proposed branch: lp:~alien-d/maria/mariadb-al13n-bug_886368
Merge into: lp:maria/5.5
Diff against target: 129 lines (+66/-38)
1 file modified
sql/mysqld.cc (+66/-38)
To merge this branch: bzr merge lp:~alien-d/maria/mariadb-al13n-bug_886368
Reviewer Review Type Date Requested Status
Maria-captains Pending
Review via email: mp+82950@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

3152. By Maarten Vanraes

see bug 886368

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'sql/mysqld.cc'
--- sql/mysqld.cc 2011-11-02 13:10:09 +0000
+++ sql/mysqld.cc 2011-11-21 23:55:27 +0000
@@ -3020,6 +3020,70 @@
3020}3020}
30213021
30223022
3023/* pthread_attr_setstacksize without so much platform-dependency */
3024/* returns the actual stack size if possible */
3025static size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize)
3026{
3027 size_t guard_size = 0;
3028
3029#if defined(__ia64__) || defined(__ia64)
3030 /*
3031 On IA64, half of the requested stack size is used for "normal stack"
3032 and half for "register stack". The space measured by check_stack_overrun
3033 is the "normal stack", so double the request to make sure we have the
3034 caller-expected amount of normal stack.
3035
3036 NOTE: there is no guarantee that the register stack can't grow faster
3037 than normal stack, so it's very unclear that we won't dump core due to
3038 stack overrun despite check_stack_overrun's efforts. Experimentation
3039 shows that in the execution_constants test, the register stack grows
3040 less than half as fast as normal stack, but perhaps other scenarios are
3041 less forgiving. If it turns out that more space is needed for the
3042 register stack, that could be forced (rather inefficiently) by using a
3043 multiplier higher than 2 here.
3044 */
3045 stacksize *= 2;
3046#endif
3047
3048 /*
3049 On many machines, the "guard space" is subtracted from the requested
3050 stack size, and that space is quite large on some platforms. So add
3051 it to our request, if we can find out what it is.
3052
3053 FIXME: autoconfiscate use of pthread_attr_getguardsize
3054 */
3055 if (pthread_attr_getguardsize(attr, &guard_size))
3056 guard_size = 0; /* if can't find it out, treat as 0 */
3057
3058 pthread_attr_setstacksize(attr, stacksize + guard_size);
3059
3060 /* Retrieve actual stack size if possible */
3061#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
3062 {
3063 size_t real_stack_size= 0;
3064 /* We must ignore real_stack_size = 0 as Solaris 2.9 can return 0 here */
3065 if (pthread_attr_getstacksize(attr, &real_stack_size) == 0 &&
3066 real_stack_size > guard_size)
3067 {
3068 real_stack_size -= guard_size;
3069 if (real_stack_size < stacksize)
3070 {
3071 if (global_system_variables.log_warnings)
3072 sql_print_warning("Asked for %ld thread stack, but got %ld",
3073 (long) stacksize, (long) real_stack_size);
3074 stacksize= real_stack_size;
3075 }
3076 }
3077 }
3078#endif
3079
3080#if defined(__ia64__) || defined(__ia64)
3081 stacksize /= 2;
3082#endif
3083 return stacksize;
3084}
3085
3086
3023static void start_signal_handler(void)3087static void start_signal_handler(void)
3024{3088{
3025 int error;3089 int error;
@@ -3030,15 +3094,7 @@
3030#if !defined(HAVE_DEC_3_2_THREADS)3094#if !defined(HAVE_DEC_3_2_THREADS)
3031 pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);3095 pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);
3032 (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);3096 (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
3033#if defined(__ia64__) || defined(__ia64)3097 (void) my_setstacksize(&thr_attr,my_thread_stack_size);
3034 /*
3035 Peculiar things with ia64 platforms - it seems we only have half the
3036 stack size in reality, so we have to double it here
3037 */
3038 pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2);
3039#else
3040 pthread_attr_setstacksize(&thr_attr,my_thread_stack_size);
3041#endif
3042#endif3098#endif
30433099
3044 mysql_mutex_lock(&LOCK_thread_count);3100 mysql_mutex_lock(&LOCK_thread_count);
@@ -4856,36 +4912,8 @@
4856 unireg_abort(1); // Will do exit4912 unireg_abort(1); // Will do exit
48574913
4858 init_signals();4914 init_signals();
4859#if defined(__ia64__) || defined(__ia64)
4860 /*
4861 Peculiar things with ia64 platforms - it seems we only have half the
4862 stack size in reality, so we have to double it here
4863 */
4864 pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size*2);
4865#else
4866 pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size);
4867#endif
4868#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE4915#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
4869 {4916 my_thread_stack_size = my_setstacksize(&connection_attrib,my_thread_stack_size);
4870 /* Retrieve used stack size; Needed for checking stack overflows */
4871 size_t stack_size= 0;
4872 pthread_attr_getstacksize(&connection_attrib, &stack_size);
4873#if defined(__ia64__) || defined(__ia64)
4874 stack_size/= 2;
4875#endif
4876 /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */
4877 if (stack_size && stack_size < my_thread_stack_size)
4878 {
4879 if (global_system_variables.log_warnings)
4880 sql_print_warning("Asked for %lu thread stack, but got %ld",
4881 my_thread_stack_size, (long) stack_size);
4882#if defined(__ia64__) || defined(__ia64)
4883 my_thread_stack_size= stack_size*2;
4884#else
4885 my_thread_stack_size= stack_size;
4886#endif
4887 }
4888 }
4889#endif4917#endif
48904918
4891 (void) thr_setconcurrency(concurrency); // 10 by default4919 (void) thr_setconcurrency(concurrency); // 10 by default

Subscribers

People subscribed via source and target branches