summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorJoerg Bruehe <joerg@mysql.com>2009-07-30 16:12:26 +0200
committerJoerg Bruehe <joerg@mysql.com>2009-07-30 16:12:26 +0200
commit9ff932336e3d42273742a4b363d2b4e05d54f6d2 (patch)
tree6478b47c0e56349b05af4780fe7cfc376c98a0d9 /config
parent46f95f0b8283999574b37438626d09e86fafa077 (diff)
downloadmariadb-git-9ff932336e3d42273742a4b363d2b4e05d54f6d2.tar.gz
Our autoconf function "MYSQL_STACK_DIRECTION" will not work
correctly if the compiler optimizes too clever. This has happaned on HP-UX 11.23 (IA64) at optimization level "+O2", causing bug#42213: Check for "stack overrun" doesn't work, server crashes Fix it by adding a pragma that prevents this optimization. As a result, it should be safe to use "+O2" on this platform (unless there is some other, optimizer-related, bug which is just currently masked because we use resudec optimization). config/ac-macros/misc.m4: Our autoconf function "MYSQL_STACK_DIRECTION" is meant to determine whether the stack grows towards higher or towards lower addresses. It does this by comparing the addresses of a variable (which is local to a recursive function) on different nesting levels. This approach requires that the function is really implemented as a recursive function, with each nested call allocating a new stack frame containing the local variable. If, however, the compiler is optimizing so clever that the recursive function is implemented by a loop, then this test will not produce correct results. This has happened on HP-UX 11.23 (IA64) when HP's compiler was called with optimization "+O2" (not with "+O1"), reported as bug#42213. Rather than starting a race with the compiler and making the function so complicated that this optimization does not happen, the idea is to prevent the optimization by adding a pragma. For HP, this is "#pragma noinline". If we encounter other compilers which also optimize too clever, we may add their pragmas here. It is a debatable issue whether such pragmas should be guarded by conditional compiling or not, the reviewers voted to do it. It seems HP has different compilers, "ANSI C" and "aCC", on the affected platform "__HP_cc" ("ANSI C") is predefined. To be on the safe side, the pragma will also take effect if HP's "aCC" compiler is used, or any other compiler on HP-UX.
Diffstat (limited to 'config')
-rw-r--r--config/ac-macros/misc.m44
1 files changed, 4 insertions, 0 deletions
diff --git a/config/ac-macros/misc.m4 b/config/ac-macros/misc.m4
index aef1eeaf935..9e575862848 100644
--- a/config/ac-macros/misc.m4
+++ b/config/ac-macros/misc.m4
@@ -583,6 +583,10 @@ fi
AC_DEFUN([MYSQL_STACK_DIRECTION],
[AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
[AC_TRY_RUN([#include <stdlib.h>
+ /* Prevent compiler optimization by HP's compiler, see bug#42213 */
+#if defined(__HP_cc) || defined (__HP_aCC) || defined (__hpux)
+#pragma noinline
+#endif
int find_stack_direction ()
{
static char *addr = 0;