vm_insnhelper.c: raise ruby_error_sysstack_gc

* vm_insnhelper.c (rb_threadptr_stack_overflow): rb_fatal is not
  available during GC.  raise the preallocated fatal error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-08-18 12:17:59 +00:00
parent bf210cfce9
commit a7bccb20f8
3 changed files with 5 additions and 1 deletions

1
eval.c
View File

@ -1930,6 +1930,7 @@ Init_eval(void)
rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */ rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
rb_vm_register_special_exception(ruby_error_reenter, rb_eFatal, "exception reentered"); rb_vm_register_special_exception(ruby_error_reenter, rb_eFatal, "exception reentered");
rb_vm_register_special_exception(ruby_error_sysstack_gc, rb_eFatal, "machine stack overflow while GC is running.");
id_signo = rb_intern_const("signo"); id_signo = rb_intern_const("signo");
id_status = rb_intern_const("status"); id_status = rb_intern_const("status");

View File

@ -455,6 +455,7 @@ enum ruby_special_exceptions {
ruby_error_reenter, ruby_error_reenter,
ruby_error_nomemory, ruby_error_nomemory,
ruby_error_sysstack, ruby_error_sysstack,
ruby_error_sysstack_gc,
ruby_error_stream_closed, ruby_error_stream_closed,
ruby_special_error_count ruby_special_error_count
}; };

View File

@ -57,7 +57,9 @@ void
rb_threadptr_stack_overflow(rb_thread_t *th) rb_threadptr_stack_overflow(rb_thread_t *th)
{ {
if (rb_during_gc()) { if (rb_during_gc()) {
rb_fatal("machine stack overflow while GC is running."); th->ec.raised_flag = RAISED_STACKOVERFLOW;
th->ec.errinfo = th->vm->special_exceptions[ruby_error_sysstack_gc];
TH_JUMP_TAG(th, TAG_RAISE);
} }
#ifdef USE_SIGALTSTACK #ifdef USE_SIGALTSTACK
threadptr_stack_overflow(th, TRUE); threadptr_stack_overflow(th, TRUE);