mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix stack overflow when out of memory
As a result of this change, no backtrace information is set for NoMemoryError (`mrb->nomem_err`). Detailes: When generating a backtrace, called `mrb_intern_lit()`, `mrb_str_new_cstr()` and `mrb_obj_iv_set()` function with `exc_debug_info()` function in `src/error.c`. If a `NoMemoryError` exception occurs at this time, the `exc_debug_info()` function will be called again, and in the same way `NoMemoryError` exception raised will result in an infinite loop to occurs stack overflow (and SIGSEGV).
This commit is contained in:
@@ -200,6 +200,7 @@ exc_debug_info(mrb_state *mrb, struct RObject *exc)
|
||||
mrb_callinfo *ci = mrb->c->ci;
|
||||
mrb_code *pc = ci->pc;
|
||||
|
||||
if (!exc || exc == mrb->nomem_err) return;
|
||||
if (mrb_obj_iv_defined(mrb, exc, mrb_intern_lit(mrb, "file"))) return;
|
||||
while (ci >= mrb->c->cibase) {
|
||||
mrb_code *err = ci->err;
|
||||
|
||||
Reference in New Issue
Block a user