Commit f11ae521 authored by Tor Didriksen's avatar Tor Didriksen

Bug#62856 Check for "stack overrun" doesn't work with gcc-4.6, server crashes

Bug#13243248 CHECK FOR "STACK OVERRUN" DOESN'T WORK WITH GCC-4.6, SERVER CRASHES

The existing check for stack direction may give wrong results
for new versions of gcc at high optimization levels.

Solution: Backport the stack-direction check from 5.5
parent 23ea92f7
...@@ -460,22 +460,23 @@ AC_DEFUN([MYSQL_STACK_DIRECTION], ...@@ -460,22 +460,23 @@ AC_DEFUN([MYSQL_STACK_DIRECTION],
#if defined(__HP_cc) || defined (__HP_aCC) || defined (__hpux) #if defined(__HP_cc) || defined (__HP_aCC) || defined (__hpux)
#pragma noinline #pragma noinline
#endif #endif
int find_stack_direction () /* Check stack direction (-1 down, 1 up) */
int f(int *a)
{ {
static char *addr = 0; int b;
auto char dummy; return(&b > a)?1:-1;
if (addr == 0)
{
addr = &dummy;
return find_stack_direction ();
}
else
return (&dummy > addr) ? 1 : -1;
} }
int main () /*
Prevent compiler optimizations by calling function
through pointer.
*/
volatile int (*ptr_f)(int *) = f;
int main()
{ {
exit (find_stack_direction() < 0); int a;
}], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1, exit(ptr_f(&a) < 0);
}
], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
ac_cv_c_stack_direction=)]) ac_cv_c_stack_direction=)])
AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
])dnl ])dnl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment