ruby-changes:63361
From: Alan <ko1@a...>
Date: Fri, 16 Oct 2020 23:24:42 +0900 (JST)
Subject: [ruby-changes:63361] 0d17cdd0ac (master): Abort on system stack overflow during GC
https://git.ruby-lang.org/ruby.git/commit/?id=0d17cdd0ac From 0d17cdd0ac3ae0f3f3608e5430b68467a6a13cc7 Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Thu, 15 Oct 2020 14:51:30 -0400 Subject: Abort on system stack overflow during GC Buggy native extensions could have mark functions that cause stack overflow. When a stack overflow happens during GC, Ruby used to recover by raising an exception, which runs the interpreter. It's not safe to run the interpreter during GC since the GC is in an inconsistent state. This could cause object allocation during GC, for example. Instead of running the interpreter and potentially causing a crash down the line, fail fast and abort. diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 275e5f7..9eedc10 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -83,7 +83,10 @@ NORETURN(MJIT_STATIC void rb_ec_stack_overflow(rb_execution_context_t *ec, int c https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L83 MJIT_STATIC void rb_ec_stack_overflow(rb_execution_context_t *ec, int crit) { - if (crit || rb_during_gc()) { + if (rb_during_gc()) { + rb_bug("system stack overflow during GC. Faulty native extension?"); + } + if (crit) { ec->raised_flag = RAISED_STACKOVERFLOW; ec->errinfo = rb_ec_vm_ptr(ec)->special_exceptions[ruby_error_stackfatal]; EC_JUMP_TAG(ec, TAG_RAISE); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/