Do not allocate new objects at machine stack overflow
This commit is contained in:
parent
cb1ea54bbf
commit
5dc155351a
Notes:
git
2025-04-24 08:29:46 +00:00
4
signal.c
4
signal.c
@ -856,7 +856,7 @@ check_stack_overflow(int sig, const uintptr_t addr, const ucontext_t *ctx)
|
||||
ec->tag = ec->tag->prev;
|
||||
}
|
||||
reset_sigmask(sig);
|
||||
rb_ec_stack_overflow(ec, crit);
|
||||
rb_ec_stack_overflow(ec, crit + 1);
|
||||
}
|
||||
}
|
||||
# else
|
||||
@ -867,7 +867,7 @@ check_stack_overflow(int sig, const void *addr)
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
if (ruby_stack_overflowed_p(th, addr)) {
|
||||
reset_sigmask(sig);
|
||||
rb_ec_stack_overflow(th->ec, FALSE);
|
||||
rb_ec_stack_overflow(th->ec, 1);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
@ -381,7 +381,7 @@ stack_check(rb_execution_context_t *ec)
|
||||
if (!rb_ec_raised_p(ec, RAISED_STACKOVERFLOW) &&
|
||||
rb_ec_stack_check(ec)) {
|
||||
rb_ec_raised_set(ec, RAISED_STACKOVERFLOW);
|
||||
rb_ec_stack_overflow(ec, FALSE);
|
||||
rb_ec_stack_overflow(ec, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,22 +79,23 @@ vm_stackoverflow(void)
|
||||
}
|
||||
|
||||
NORETURN(void rb_ec_stack_overflow(rb_execution_context_t *ec, int crit));
|
||||
/* critical level
|
||||
* 0: VM stack overflow or about to machine stack overflow
|
||||
* 1: machine stack overflow but may be recoverable
|
||||
* 2: fatal machine stack overflow
|
||||
*/
|
||||
void
|
||||
rb_ec_stack_overflow(rb_execution_context_t *ec, int crit)
|
||||
{
|
||||
if (rb_during_gc()) {
|
||||
rb_bug("system stack overflow during GC. Faulty native extension?");
|
||||
}
|
||||
if (crit) {
|
||||
if (crit > 1) {
|
||||
ec->raised_flag = RAISED_STACKOVERFLOW;
|
||||
ec->errinfo = rb_ec_vm_ptr(ec)->special_exceptions[ruby_error_stackfatal];
|
||||
EC_JUMP_TAG(ec, TAG_RAISE);
|
||||
}
|
||||
#ifdef USE_SIGALTSTACK
|
||||
ec_stack_overflow(ec, TRUE);
|
||||
#else
|
||||
ec_stack_overflow(ec, FALSE);
|
||||
#endif
|
||||
ec_stack_overflow(ec, crit == 0);
|
||||
}
|
||||
|
||||
static inline void stack_check(rb_execution_context_t *ec);
|
||||
|
Loading…
x
Reference in New Issue
Block a user