From dae17511aad293e3a501703db0582754d75a30cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=9A=93?= Date: Sun, 13 Apr 2025 22:18:41 -0400 Subject: [PATCH] Rescue all Ruby errors in libretro builds instead of only `StandardError`s `rb_rescue` only catches `StandardError`s, which doesn't include things like Ruby syntax errors that we'd like to catch. We need to explicitly use `rb_rescue2` to catch `Exception` in order to catch everything. --- binding-sandbox/binding-sandbox.h | 2 +- src/core.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/binding-sandbox/binding-sandbox.h b/binding-sandbox/binding-sandbox.h index 34a5db31..0f39c42d 100644 --- a/binding-sandbox/binding-sandbox.h +++ b/binding-sandbox/binding-sandbox.h @@ -87,7 +87,7 @@ namespace mkxp_sandbox { SANDBOX_AWAIT_AND_SET(value, rb_class_new_instance, 0, NULL, sb()->rb_cArray()); SANDBOX_AWAIT(rb_ary_push, value, string); SANDBOX_AWAIT(rb_ary_push, value, filename); - SANDBOX_AWAIT_AND_SET(value, rb_rescue, func, value, rescue, SANDBOX_NIL); + SANDBOX_AWAIT_AND_SET(value, rb_rescue2, func, value, rescue, SANDBOX_NIL, sb()->rb_eException(), 0); } return value; diff --git a/src/core.cpp b/src/core.cpp index 576b28ea..8bed2009 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -145,7 +145,7 @@ static VALUE rescue(VALUE arg, VALUE exception) { SANDBOX_COROUTINE(main, void operator()() { BOOST_ASIO_CORO_REENTER (this) { - SANDBOX_AWAIT(rb_rescue, func, 0, rescue, 0); + SANDBOX_AWAIT(rb_rescue2, func, 0, rescue, 0, sb()->rb_eException(), 0); } } )