From 0a2574cd3a955535e65a5edef320ead08e8e134d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 11 Sep 2018 23:19:52 +0200 Subject: [PATCH] Now it breaks the ruby 1.8.x tests ... grrr --- src/rba/rba/rba.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rba/rba/rba.cc b/src/rba/rba/rba.cc index c87e14d02..db89177cf 100644 --- a/src/rba/rba/rba.cc +++ b/src/rba/rba/rba.cc @@ -1862,10 +1862,21 @@ RubyInterpreter::initialize (int &main_argc, char **main_argv, int (*main_func) // fault on exception. #if HAVE_RUBY_VERSION_CODE<10900 + + // Remove setters for $0 and $PROGRAM_NAME (still both are linked) because + // the setter does strange things with the process and the argv, specifically argv[0] above. + // This is no longer the case for 1.9 and 2.x. On ruby 2.5.0 crashes have been observed + // with this code, so it got moved into the 1.8.x branch. + static VALUE argv0 = Qnil; + argv0 = c2ruby (main_argv [0]); + rb_define_hooked_variable("$0", &argv0, 0, 0); + rb_define_hooked_variable("$PROGRAM_NAME", &argv0, 0, 0); + // 1.8.x does not have ruby_run_node ruby_options(argc, argv); ruby_run(); int res = 0; + #else int res = ruby_run_node (ruby_options (argc, argv)); #endif