From f35b522256d04a8504c615a89491d8929d1b5a11 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 10 Sep 2018 21:36:27 +0000 Subject: [PATCH] Fixed a segfault on Ruby initialization found on OpenSuSE 15 with Ruby 2.5.0 and gcc 7.3.1 in release mode --- src/rba/rba/rba.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rba/rba/rba.cc b/src/rba/rba/rba.cc index 1d0ee282e..69fff8bca 100644 --- a/src/rba/rba/rba.cc +++ b/src/rba/rba/rba.cc @@ -1768,18 +1768,24 @@ static VALUE run_app_func (VALUE) int RubyInterpreter::initialize (int &main_argc, char **main_argv, int (*main_func) (int &, char **)) { + static char argv1[] = "-e"; + static char argv2[] = "__run_app__"; + int argc = 3; char *argv[3]; argv[0] = main_argv[0]; // Hint: to keep ruby_options from reading stdin, we simulate a "-e" option with an empty script - argv[1] = (char *)"-e"; - argv[2] = (char *)"__run_app__"; + argv[1] = argv1; + argv[2] = argv2; +#if 0 +// According to the comments in ruby.c, this should not be required any longer: #if HAVE_RUBY_VERSION_CODE>=10900 // Make sure we call ruby_sysinit because otherwise the program will crash char **argvp = argv; int argcp = argc; ruby_sysinit (&argcp, &argvp); +#endif #endif {