Fix crashes when starting up libretro Ruby sandbox (hopefully)

Guys, I think I'm going insane. Every time I build the libretro Ruby
sandbox with a different version of Ruby, or even when I build Ruby at a
different path on my computer, there's some chance that the builds
produced with that version of Ruby and/or that path on my computer
result in Ruby crashing on startup in libretro builds. I've been
tweaking these command-line arguments that are passed to Ruby for a
while now, and I *think* these are the correct ones that will stop Ruby
from crashing.
This commit is contained in:
刘皓 2025-01-17 01:23:18 -05:00
parent 510f1b0211
commit 1473416a5a
No known key found for this signature in database
GPG key ID: 7901753DB465B711
2 changed files with 3 additions and 5 deletions

View file

@ -70,7 +70,8 @@ sandbox::sandbox(const char *game_path) : ruby(new struct w2c_ruby), wasi(new wa
// Determine Ruby command-line arguments
std::vector<std::string> args{"mkxp-z"};
args.push_back("-e ''");
args.push_back("-v");
args.push_back("-e ");
if (MJIT_ENABLED) {
std::string verboseLevel("--mjit-verbose=");
std::string maxCache("--mjit-max-cache=");
@ -93,12 +94,8 @@ sandbox::sandbox(const char *game_path) : ruby(new struct w2c_ruby), wasi(new wa
std::strcpy((char *)WASM_MEM(arg_buf), args[i].c_str());
WASM_SET(usize, argv_buf + i * sizeof(usize), arg_buf);
}
usize sysinit_buf = sandbox_malloc(sizeof(usize) + sizeof(u32));
WASM_SET(u32, sysinit_buf + sizeof(usize), args.size());
WASM_SET(usize, sysinit_buf, argv_buf);
// Pass the command-line arguments to Ruby
w2c_ruby_ruby_sysinit(RB, sysinit_buf + sizeof(usize), sysinit_buf);
AWAIT(w2c_ruby_ruby_init_stack(RB, ruby->w2c_0x5F_stack_pointer));
AWAIT(w2c_ruby_ruby_init(RB));
usize node;

View file

@ -1184,6 +1184,7 @@ static void mriBindingExecute() {
ruby_init();
std::vector<const char*> rubyArgsC{"mkxp-z"};
rubyArgsC.push_back("-v");
rubyArgsC.push_back("-e ");
void *node;
if (conf.jit.enabled) {