diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2011-12-20 14:38:53 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2011-12-20 14:38:53 +0000 |
commit | a69f9be8c5fd60296550ffb23de9a2e9d4c372e4 (patch) | |
tree | c51bc599c18c98325309cd34f214bd81529c6c64 /asmrun/signals_asm.c | |
parent | d0667f4e52167a4a415d29f76289750cf9515652 (diff) |
PR#4746: wrong detection of stack overflows in native code under Linux
(quick fix, will have to find something better)
testsuite/tests/runtime-errors: make the test output independent of
the stack size; add a "ulimit -s" just to make sure stack is limited.
testsuite/tests/asmcomp: updated to compile again.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11898 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'asmrun/signals_asm.c')
-rw-r--r-- | asmrun/signals_asm.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/asmrun/signals_asm.c b/asmrun/signals_asm.c index 5b3f9955e..556bd945b 100644 --- a/asmrun/signals_asm.c +++ b/asmrun/signals_asm.c @@ -175,6 +175,15 @@ DECLARE_SIGNAL_HANDLER(trap_handler) static char * system_stack_top; static char sig_alt_stack[SIGSTKSZ]; +#if defined(SYS_linux) +/* PR#4746: recent Linux kernels with support for stack randomization + silently add 2 Mb of stack space on top of RLIMIT_STACK. + 2 Mb = 0x200000, to which we add 8 kB (=0x2000) for overshoot. */ +#define EXTRA_STACK 0x202000 +#else +#define EXTRA_STACK 0x2000 +#endif + DECLARE_SIGNAL_HANDLER(segv_handler) { struct rlimit limit; @@ -189,7 +198,7 @@ DECLARE_SIGNAL_HANDLER(segv_handler) if (((uintnat) fault_addr & (sizeof(intnat) - 1)) == 0 && getrlimit(RLIMIT_STACK, &limit) == 0 && fault_addr < system_stack_top - && fault_addr >= system_stack_top - limit.rlim_cur - 0x2000 + && fault_addr >= system_stack_top - limit.rlim_cur - EXTRA_STACK #ifdef CONTEXT_PC && Is_in_code_area(CONTEXT_PC) #endif |