Revu configuration de STACK_OVERFLOW_DETECTION
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5723 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
db806efb49
commit
727d925a85
|
@ -41,15 +41,10 @@ static void segv_handler(int signo, siginfo_t * info, void * context)
|
|||
}
|
||||
}
|
||||
|
||||
void f(char * c);
|
||||
void g(char * c) { char d[1024]; f(d); }
|
||||
void f(char * c) { char d[1024]; g(d); }
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct sigaltstack stk;
|
||||
struct sigaction act;
|
||||
struct rlimit limit;
|
||||
|
||||
stk.ss_sp = sig_alt_stack;
|
||||
stk.ss_size = SIGSTKSZ;
|
||||
|
@ -63,10 +58,11 @@ int main(int argc, char ** argv)
|
|||
#endif
|
||||
sigemptyset(&act.sa_mask);
|
||||
system_stack_top = (char *) &act;
|
||||
limit.rlim_max = limit.rlim_cur = 0x20000;
|
||||
if (sigaltstack(&stk, NULL) != 0) { perror("sigaltstack"); return 2; }
|
||||
if (sigaction(SIGSEGV, &act, NULL) != 0) { perror("sigaction"); return 2; }
|
||||
if (setrlimit(RLIMIT_STACK, &limit) != 0) { perror("setrlimit"); return 2; }
|
||||
f(NULL);
|
||||
return 2;
|
||||
/* We used to trigger a stack overflow at this point to test whether
|
||||
the code above works, but this causes problems with POSIX threads
|
||||
on some BSD systems. So, instead, we just test that all this
|
||||
code compiles, indicating that the required syscalls are there. */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1003,11 +1003,15 @@ fi
|
|||
# Determine if system stack overflows can be detected
|
||||
|
||||
case "$arch,$system" in
|
||||
i386,linux_elf|i386,bsd_elf)
|
||||
i386,*)
|
||||
if ./runtest -DTARGET_$arch -DSYS_$system stackov.c; then
|
||||
echo "System stack overflow can be detected."
|
||||
echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;;
|
||||
echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h
|
||||
else
|
||||
echo "Cannot detect system stack overflow."
|
||||
fi;;
|
||||
*)
|
||||
echo "Cannot detect system stack overflow.";;
|
||||
echo "Cannot detect system stack overflow.";;
|
||||
esac
|
||||
|
||||
# Determine the target architecture for the "num" library
|
||||
|
|
Loading…
Reference in New Issue