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:
dearblue
2019-01-19 13:05:09 +09:00
parent da7d7f881b
commit fef1c152ce
+1
View File
@@ -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;