Extend mruby stack when keep is bigger than room; fix
But still cause stack overflow error due to infinite recursion.
To prevent overflow, we need to add different stack depth check.
MODIFY
src/vm.c
src/vm.c
@@ -169,6 +169,9 @@ stack_extend_alloc(mrb_state *mrb, int room, int keep)
static inline void
stack_extend(mrb_state *mrb, int room, int keep)
{
+ if (room < keep) {
+ room = keep;
+ }
if (mrb->c->stack + room >= mrb->c->stend) {
stack_extend_alloc(mrb, room, keep);
}

Extend mruby stack when keep is bigger than room; fix #3421

But #3421 still cause stack overflow error due to infinite recursion.
To prevent overflow, we need to add different stack depth check.