gc.c: rb_threadptr_stack_check

* gc.c (rb_threadptr_stack_check): check probability of stack
  overflow for the given thread, not the current thread.

* vm_eval.c (stack_check): check the given thread, not the current
  thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-04-17 00:10:47 +00:00
Родитель b0d3649479
Коммит 61d9da258d
3 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -268,6 +268,7 @@ int rb_threadptr_reset_raised(rb_thread_t *th);
#define rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f))
#define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0)
#define rb_thread_raised_clear(th) ((th)->raised_flag = 0)
int rb_threadptr_stack_check(rb_thread_t *th);
VALUE rb_f_eval(int argc, const VALUE *argv, VALUE self);
VALUE rb_make_exception(int argc, const VALUE *argv);

6
gc.c
Просмотреть файл

@ -3965,6 +3965,12 @@ stack_check(rb_thread_t *th, int water_mark)
#define STACKFRAME_FOR_CALL_CFUNC 512
int
rb_threadptr_stack_check(rb_thread_t *th)
{
return stack_check(th, STACKFRAME_FOR_CALL_CFUNC);
}
int
ruby_stack_check(void)
{

Просмотреть файл

@ -300,7 +300,8 @@ rb_current_receiver(void)
static inline void
stack_check(rb_thread_t *th)
{
if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) && ruby_stack_check()) {
if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) &&
rb_threadptr_stack_check(th)) {
rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
rb_exc_raise(sysstack_error);
}