Rescue all Ruby errors in libretro builds instead of only StandardErrors

`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.
This commit is contained in:
刘皓 2025-04-13 22:18:41 -04:00
parent 06819fb9a9
commit dae17511aa
No known key found for this signature in database
GPG key ID: 7901753DB465B711
2 changed files with 2 additions and 2 deletions

View file

@ -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;

View file

@ -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);
}
}
)