зеркало из https://github.com/github/ruby.git
gc.c: PREVENT_STACK_OVERFLOW
* gc.c (PREVENT_STACK_OVERFLOW): define TRUE to try preventing stack overflow before actually happens. * gc.c (stack_check): parameterize thread pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d2b68234de
Коммит
b0d3649479
18
gc.c
18
gc.c
|
@ -3937,12 +3937,18 @@ ruby_stack_length(VALUE **p)
|
|||
return STACK_LENGTH;
|
||||
}
|
||||
|
||||
#ifndef PREVENT_STACK_OVERFLOW
|
||||
#if !(defined(POSIX_SIGNAL) && defined(SIGSEGV) && defined(HAVE_SIGALTSTACK))
|
||||
# define PREVENT_STACK_OVERFLOW 1
|
||||
#else
|
||||
# define PREVENT_STACK_OVERFLOW 0
|
||||
#endif
|
||||
#endif
|
||||
#if PREVENT_STACK_OVERFLOW
|
||||
static int
|
||||
stack_check(int water_mark)
|
||||
stack_check(rb_thread_t *th, int water_mark)
|
||||
{
|
||||
int ret;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
SET_STACK_END;
|
||||
ret = STACK_LENGTH > STACK_LEVEL_MAX - water_mark;
|
||||
#ifdef __ia64
|
||||
|
@ -3953,6 +3959,8 @@ stack_check(int water_mark)
|
|||
#endif
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#define stack_check(th, water_mark) FALSE
|
||||
#endif
|
||||
|
||||
#define STACKFRAME_FOR_CALL_CFUNC 512
|
||||
|
@ -3960,11 +3968,7 @@ stack_check(int water_mark)
|
|||
int
|
||||
ruby_stack_check(void)
|
||||
{
|
||||
#if defined(POSIX_SIGNAL) && defined(SIGSEGV) && defined(HAVE_SIGALTSTACK)
|
||||
return 0;
|
||||
#else
|
||||
return stack_check(STACKFRAME_FOR_CALL_CFUNC);
|
||||
#endif
|
||||
return stack_check(GET_THREAD(), STACKFRAME_FOR_CALL_CFUNC);
|
||||
}
|
||||
|
||||
ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
|
||||
|
|
Загрузка…
Ссылка в новой задаче