diff options
author | Hans de Graaff <hans@degraaff.org> | 2017-09-15 09:32:48 +0200 |
---|---|---|
committer | Hans de Graaff <hans@degraaff.org> | 2017-09-15 09:32:48 +0200 |
commit | afeaabb79e38cb75e64da58fa68385de4f745b77 (patch) | |
tree | 4e7c1d15f6fd3d45227ae87b0730d84641aaeae8 | |
parent | Patch set for 2.3.4-r3 (diff) | |
download | ruby-scripts-afeaabb79e38cb75e64da58fa68385de4f745b77.tar.gz ruby-scripts-afeaabb79e38cb75e64da58fa68385de4f745b77.tar.bz2 ruby-scripts-afeaabb79e38cb75e64da58fa68385de4f745b77.zip |
Add new ruby patchsets
37 files changed, 1999 insertions, 0 deletions
diff --git a/patchsets/patches-2.2.7-r4/001_ia64.patch b/patchsets/patches-2.2.7-r4/001_ia64.patch new file mode 100644 index 0000000..e1e9c89 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/001_ia64.patch @@ -0,0 +1,62 @@ +Bug: https://bugs.gentoo.org/show_bug.cgi?id=561780 + +fix crash on register stack mark/sweep pass + +The crash looks like + + Program received signal SIGSEGV, Segmentation fault. + mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + 3297 v = *x; + (gdb) bt + #0 mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + #1 0x400000000014a040 in gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 + #2 0x400000000014b3a0 in mark_current_machine_context (objspace=0x6000000000045db0, th=0x60000000000455b0) at gc.c:3500 + #3 0x400000000014dfe0 in gc_mark_roots (objspace=0x6000000000045db0, full_mark=0, categoryp=0x0) at gc.c:4105 + #4 0x400000000014e6b0 in gc_marks_body (objspace=0x6000000000045db0, full_mark=0) at gc.c:4164 + #5 0x400000000014f260 in gc_marks (objspace=0x6000000000045db0, full_mark=0) at gc.c:4526 + #6 0x40000000001525c0 in garbage_collect_body (objspace=0x6000000000045db0, full_mark=0, immediate_sweep=0, reason=256) at gc.c:5024 + #7 0x400000000013c010 in heap_prepare_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1219 + #8 0x400000000013c140 in heap_get_freeobj_from_next_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1237 + #9 0x400000000013c360 in heap_get_freeobj (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1259 + #10 0x400000000013c950 in newobj_of (klass=0, flags=40, v1=0, v2=0, v3=0) at gc.c:1303 + #11 0x400000000013ccc0 in rb_newobj_of (klass=0, flags=40) at gc.c:1356 + #12 0x4000000000163740 in hash_alloc (klass=0) at hash.c:289 + #13 0x4000000000163860 in rb_hash_new () at hash.c:309 + #14 0x400000000050e420 in Init_BareVM () at vm.c:2822 + #15 0x40000000000f6b60 in ruby_setup () at eval.c:54 + #16 0x40000000000f6f50 in ruby_init () at eval.c:75 + #17 0x400000000001b010 in main (argc=9, argv=0x60000fffffffb1d8) at main.c:35 + +The problem here is in call + gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 +where 'start' (native_main_thread.register_stack_start) +is supposed to be stack start but it's not initialized. + +The initialization of 'native_main_thread.register_stack_start' +is supposed to be done in 'ruby_init_stack()'. + +But code under 'MAINSTACKADDR_AVAILABLE' exits early. +The fix is to move 'register_stack_start' earlier. + +diff --git a/thread_pthread.c b/thread_pthread.c +index c8a7a16..9ad448b 100644 +--- a/thread_pthread.c ++++ b/thread_pthread.c +@@ -722,2 +722,8 @@ ruby_init_stack(volatile VALUE *addr + native_main_thread.id = pthread_self(); ++#ifdef __ia64 ++ if (!native_main_thread.register_stack_start || ++ (VALUE*)bsp < native_main_thread.register_stack_start) { ++ native_main_thread.register_stack_start = (VALUE*)bsp; ++ } ++#endif + #if MAINSTACKADDR_AVAILABLE +@@ -745,8 +751,2 @@ ruby_init_stack(volatile VALUE *addr + #endif +-#ifdef __ia64 +- if (!native_main_thread.register_stack_start || +- (VALUE*)bsp < native_main_thread.register_stack_start) { +- native_main_thread.register_stack_start = (VALUE*)bsp; +- } +-#endif + { diff --git a/patchsets/patches-2.2.7-r4/002_json-heap-exposure.patch b/patchsets/patches-2.2.7-r4/002_json-heap-exposure.patch new file mode 100644 index 0000000..79953d6 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/002_json-heap-exposure.patch @@ -0,0 +1,82 @@ +diff --git ext/json/generator/generator.c ext/json/generator/generator.c +index f56ac09cd2..ae0e73fcbc 100644 +--- ext/json/generator/generator.c ++++ ext/json/generator/generator.c +@@ -301,7 +301,7 @@ static char *fstrndup(const char *ptr, unsigned long len) { + char *result; + if (len <= 0) return NULL; + result = ALLOC_N(char, len); +- memccpy(result, ptr, 0, len); ++ memcpy(result, ptr, len); + return result; + } + +@@ -1055,7 +1055,7 @@ static VALUE cState_indent_set(VALUE self, VALUE indent) + } + } else { + if (state->indent) ruby_xfree(state->indent); +- state->indent = strdup(RSTRING_PTR(indent)); ++ state->indent = fstrndup(RSTRING_PTR(indent), len); + state->indent_len = len; + } + return Qnil; +@@ -1093,7 +1093,7 @@ static VALUE cState_space_set(VALUE self, VALUE space) + } + } else { + if (state->space) ruby_xfree(state->space); +- state->space = strdup(RSTRING_PTR(space)); ++ state->space = fstrndup(RSTRING_PTR(space), len); + state->space_len = len; + } + return Qnil; +@@ -1129,7 +1129,7 @@ static VALUE cState_space_before_set(VALUE self, VALUE space_before) + } + } else { + if (state->space_before) ruby_xfree(state->space_before); +- state->space_before = strdup(RSTRING_PTR(space_before)); ++ state->space_before = fstrndup(RSTRING_PTR(space_before), len); + state->space_before_len = len; + } + return Qnil; +@@ -1166,7 +1166,7 @@ static VALUE cState_object_nl_set(VALUE self, VALUE object_nl) + } + } else { + if (state->object_nl) ruby_xfree(state->object_nl); +- state->object_nl = strdup(RSTRING_PTR(object_nl)); ++ state->object_nl = fstrndup(RSTRING_PTR(object_nl), len); + state->object_nl_len = len; + } + return Qnil; +@@ -1201,7 +1201,7 @@ static VALUE cState_array_nl_set(VALUE self, VALUE array_nl) + } + } else { + if (state->array_nl) ruby_xfree(state->array_nl); +- state->array_nl = strdup(RSTRING_PTR(array_nl)); ++ state->array_nl = fstrndup(RSTRING_PTR(array_nl), len); + state->array_nl_len = len; + } + return Qnil; +diff --git ext/json/generator/generator.h ext/json/generator/generator.h +index ddd1aa8a30..395d71e9d3 100644 +--- ext/json/generator/generator.h ++++ ext/json/generator/generator.h +@@ -1,7 +1,6 @@ + #ifndef _GENERATOR_H_ + #define _GENERATOR_H_ + +-#include <string.h> + #include <math.h> + #include <ctype.h> + +diff --git ext/json/lib/json/version.rb ext/json/lib/json/version.rb +index 47cdcd607c..579697c9d7 100644 +--- ext/json/lib/json/version.rb ++++ ext/json/lib/json/version.rb +@@ -1,6 +1,6 @@ + module JSON + # JSON version +- VERSION = '1.8.1' ++ VERSION = '1.8.1.1' + VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: + VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: + VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: diff --git a/patchsets/patches-2.2.7-r4/004_gfbsd7.patch b/patchsets/patches-2.2.7-r4/004_gfbsd7.patch new file mode 100644 index 0000000..450d714 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/004_gfbsd7.patch @@ -0,0 +1,37 @@ +--- configure.in.orig 2013-05-05 19:36:02.800254192 +0200 ++++ configure.in 2013-05-05 19:37:56.573346196 +0200 +@@ -2156,7 +2156,7 @@ + fi + + AS_CASE(["$target_os"], +-[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl], [ ++[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl | freebsd* | dragonfly*], [ + if test "$rb_cv_binary_elf" = no; then + with_dln_a_out=yes + else +@@ -2249,7 +2249,7 @@ + [bsdi3*], [ AS_CASE(["$CC"], + [*shlicc*], [ : ${LDSHARED='$(CC) -r'} + rb_cv_dlopen=yes])], +- [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ ++ [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | freebsd7*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" +@@ -2262,7 +2262,6 @@ + [freebsd*|dragonfly*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -rdynamic" + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@' + else + test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable' +@@ -2638,7 +2637,7 @@ + [sunos4*], [ + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + ], +- [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu], [ ++ [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu | freebsd7*], [ + LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'" $LDFLAGS_OPTDIR" + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + if test "$load_relative" = yes; then diff --git a/patchsets/patches-2.2.7-r4/005_no-undefined-ext.patch b/patchsets/patches-2.2.7-r4/005_no-undefined-ext.patch new file mode 100644 index 0000000..f279932 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/005_no-undefined-ext.patch @@ -0,0 +1,11 @@ +--- ruby-1.9.3-preview1.orig/configure.in ++++ ruby-1.9.3-preview1/configure.in +@@ -2038,7 +2038,7 @@ if test "$with_dln_a_out" != yes; then + [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -Wl,-export-dynamic" ++ LDFLAGS="$LDFLAGS -Wl,-export-dynamic -Wl,--no-undefined" + fi + rb_cv_dlopen=yes], + [interix*], [ : ${LDSHARED='$(CC) -shared'} diff --git a/patchsets/patches-2.2.7-r4/006_tcltk1.patch b/patchsets/patches-2.2.7-r4/006_tcltk1.patch new file mode 100644 index 0000000..a0e7444 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/006_tcltk1.patch @@ -0,0 +1,27 @@ +From ebd0fc80d62eeb7b8556522256f8d035e013eb65 Mon Sep 17 00:00:00 2001 +From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Sun, 2 Aug 2015 01:27:31 +0000 +Subject: [PATCH] tcltklib.c: check argument + +* ext/tk/tcltklib.c (ip_cancel_eval_core): check argument type and + length. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + ext/tk/tcltklib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c +index afcee3b..e305c13 100644 +--- a/ext/tk/tcltklib.c ++++ b/ext/tk/tcltklib.c +@@ -7745,7 +7745,8 @@ ip_cancel_eval_core(interp, msg, flag) + if (NIL_P(msg)) { + msg_obj = NULL; + } else { +- msg_obj = Tcl_NewStringObj(RSTRING_PTR(msg), RSTRING_LEN(msg)); ++ char *s = StringValuePtr(msg); ++ msg_obj = Tcl_NewStringObj(s, RSTRING_LENINT(msg)); + Tcl_IncrRefCount(msg_obj); + } + diff --git a/patchsets/patches-2.2.7-r4/007_tcltk2.patch b/patchsets/patches-2.2.7-r4/007_tcltk2.patch new file mode 100644 index 0000000..2357898 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/007_tcltk2.patch @@ -0,0 +1,110 @@ +From d098136e3f62a4879a7d7cd34bbd50f482ba3331 Mon Sep 17 00:00:00 2001 +From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Tue, 9 Aug 2016 05:05:11 +0000 +Subject: [PATCH] tcltklib.c: use StringValueCStr [ci skip] + +* ext/tk/tcltklib.c (set_max_block_time, tcl_protect_core, + ip_init, ip_create_slave_core, get_obj_from_str, + ip_cancel_eval_core, lib_set_system_encoding, + alloc_invoke_arguments, lib_merge_tklist): use StringValueCStr + instead of StringValuePtr for values to be passed to Tcl + interperter. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + ext/tk/tcltklib.c | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c +index 430c934..721f497 100644 +--- a/ext/tk/tcltklib.c ++++ b/ext/tk/tcltklib.c +@@ -3303,7 +3303,7 @@ tcl_protect_core(interp, proc, data) /* should not raise exception */ + DUMP1("set backtrace"); + if (!NIL_P(backtrace = rb_funcallv(exc, ID_backtrace, 0, 0))) { + backtrace = rb_ary_join(backtrace, rb_str_new2("\n")); +- Tcl_AddErrorInfo(interp, StringValuePtr(backtrace)); ++ Tcl_AddErrorInfo(interp, StringValueCStr(backtrace)); + } + + rb_thread_critical = thr_crit_bup; +@@ -6208,19 +6208,19 @@ ip_init(argc, argv, self) + /* without Tk */ + with_tk = 0; + } else { +- /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */ +- Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY); ++ /* Tcl_SetVar(ptr->ip, "argv", StringValueCStr(opts), 0); */ ++ Tcl_SetVar(ptr->ip, "argv", StringValueCStr(opts), TCL_GLOBAL_ONLY); + Tcl_Eval(ptr->ip, "set argc [llength $argv]"); + } + case 1: + /* argv0 */ + if (!NIL_P(argv0)) { +- if (strncmp(StringValuePtr(argv0), "-e", 3) == 0 +- || strncmp(StringValuePtr(argv0), "-", 2) == 0) { ++ if (strncmp(StringValueCStr(argv0), "-e", 3) == 0 ++ || strncmp(StringValueCStr(argv0), "-", 2) == 0) { + Tcl_SetVar(ptr->ip, "argv0", "ruby", TCL_GLOBAL_ONLY); + } else { +- /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */ +- Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), ++ /* Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0), 0); */ ++ Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0), + TCL_GLOBAL_ONLY); + } + } +@@ -6420,7 +6420,7 @@ ip_create_slave_core(interp, argc, argv) + slave->allow_ruby_exit = 0; + slave->return_value = 0; + +- slave->ip = Tcl_CreateSlave(master->ip, StringValuePtr(name), safe); ++ slave->ip = Tcl_CreateSlave(master->ip, StringValueCStr(name), safe); + if (slave->ip == NULL) { + rb_thread_critical = thr_crit_bup; + return rb_exc_new2(rb_eRuntimeError, +@@ -6896,7 +6896,7 @@ static Tcl_Obj * + get_obj_from_str(str) + VALUE str; + { +- const char *s = StringValuePtr(str); ++ const char *s = StringValueCStr(str); + + #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 + return Tcl_NewStringObj((char*)s, RSTRING_LEN(str)); +@@ -7744,7 +7744,7 @@ ip_cancel_eval_core(interp, msg, flag) + if (NIL_P(msg)) { + msg_obj = NULL; + } else { +- char *s = StringValuePtr(msg); ++ char *s = StringValueCStr(msg); + msg_obj = Tcl_NewStringObj(s, RSTRING_LENINT(msg)); + Tcl_IncrRefCount(msg_obj); + } +@@ -8409,7 +8409,7 @@ lib_set_system_encoding(self, enc_name) + + enc_name = rb_funcallv(enc_name, ID_to_s, 0, 0); + if (Tcl_SetSystemEncoding((Tcl_Interp *)NULL, +- StringValuePtr(enc_name)) != TCL_OK) { ++ StringValueCStr(enc_name)) != TCL_OK) { + rb_raise(rb_eArgError, "unknown encoding name '%s'", + RSTRING_PTR(enc_name)); + } +@@ -8850,7 +8850,7 @@ alloc_invoke_arguments(argc, argv) + Tcl_Preserve((ClientData)av); /* XXXXXXXX */ + #endif + for (i = 0; i < argc; ++i) { +- av[i] = strdup(StringValuePtr(argv[i])); ++ av[i] = strdup(StringValueCStr(argv[i])); + } + av[argc] = NULL; + #endif +@@ -9854,7 +9854,7 @@ lib_merge_tklist(argc, argv, obj) + len = 1; + for(num = 0; num < argc; num++) { + if (OBJ_TAINTED(argv[num])) taint_flag = 1; +- dst = StringValuePtr(argv[num]); ++ dst = StringValueCStr(argv[num]); + #if TCL_MAJOR_VERSION >= 8 + len += Tcl_ScanCountedElement(dst, RSTRING_LENINT(argv[num]), + &flagPtr[num]) + 1; diff --git a/patchsets/patches-2.2.7-r4/008-net-smtp-validation.patch b/patchsets/patches-2.2.7-r4/008-net-smtp-validation.patch new file mode 100644 index 0000000..0b30c99 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/008-net-smtp-validation.patch @@ -0,0 +1,39 @@ +From 0827a7e52ba3d957a634b063bf5a391239b9ffee Mon Sep 17 00:00:00 2001 +From: shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Wed, 8 Jun 2016 07:06:57 +0000 +Subject: [PATCH] * lib/net/smtp.rb (getok, get_response): raise an + ArgumentError when CR or LF is included in a line, because they are not + allowed in RFC5321. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + lib/net/smtp.rb | 9 +++++++++ + +diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb +index 250293bdbe21..a7130a593b40 100644 +--- a/lib/net/smtp.rb ++++ b/lib/net/smtp.rb +@@ -926,7 +926,15 @@ def quit + + private + ++ def validate_line(line) ++ # A bare CR or LF is not allowed in RFC5321. ++ if /[\r\n]/ =~ line ++ raise ArgumentError, "A line must not contain CR or LF" ++ end ++ end ++ + def getok(reqline) ++ validate_line reqline + res = critical { + @socket.writeline reqline + recv_response() +@@ -936,6 +944,7 @@ def getok(reqline) + end + + def get_response(reqline) ++ validate_line reqline + @socket.writeline reqline + recv_response() + end diff --git a/patchsets/patches-2.2.7-r4/009_no-gems.patch b/patchsets/patches-2.2.7-r4/009_no-gems.patch new file mode 100644 index 0000000..a67cbf8 --- /dev/null +++ b/patchsets/patches-2.2.7-r4/009_no-gems.patch @@ -0,0 +1,88 @@ +--- tool/rbinstall.rb.~1~ 2015-03-25 04:33:14.000000000 +0100 ++++ tool/rbinstall.rb 2015-04-14 07:07:01.169073427 +0200 +@@ -654,83 +654,11 @@ + # :startdoc: + + install?(:ext, :comm, :gem) do +- $:.unshift(File.join(srcdir, "lib")) +- require("rubygems.rb") +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "default gems", gem_dir, directories +- +- spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0]) +- default_spec_dir = "#{spec_dir}/default" +- makedirs(default_spec_dir) +- +- gems = {} +- File.foreach(File.join(srcdir, "defs/default_gems")) do |line| +- line.chomp! +- line.sub!(/\s*#.*/, '') +- next if line.empty? +- words = [] +- line.scan(/\G\s*([^\[\]\s]+|\[([^\[\]]*)\])/) do +- words << ($2 ? $2.split : $1) +- end +- name, base_dir, src, execs = *words +- next unless name and base_dir and src +- +- src = File.join(srcdir, src) +- base_dir = File.join(srcdir, base_dir) +- specgen = RbInstall::Specs::Generator.new(name, base_dir, src, execs || []) +- gems[name] ||= specgen +- end +- +- Dir.glob(srcdir+"/{lib,ext}/**/*.gemspec").each do |src| +- specgen = RbInstall::Specs::Reader.new(src) +- gems[specgen.gemspec.name] ||= specgen +- end +- +- gems.sort.each do |name, specgen| +- gemspec = specgen.gemspec +- base_dir = specgen.src.sub(/\A#{Regexp.escape(srcdir)}\//, "") +- full_name = "#{gemspec.name}-#{gemspec.version}" +- +- puts "#{" "*30}#{gemspec.name} #{gemspec.version}" +- gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec") +- open_for_install(gemspec_path, $data_mode) do +- specgen.spec_source +- end +- +- unless gemspec.executables.empty? then +- bin_dir = File.join(gem_dir, 'gems', full_name, 'bin') +- makedirs(bin_dir) +- +- execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)} +- install(execs, bin_dir, :mode => $prog_mode) +- end +- end ++ # gems are unbundled in Gentoo. + end + + install?(:ext, :comm, :gem) do +- begin +- require "zlib" +- rescue LoadError +- end +- if defined?(Zlib) +- require 'pathname' +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "bundle gems", gem_dir, directories +- Dir.glob(srcdir+'/gems/*.gem').each do |gem| +- Gem.install gem, Gem::Requirement.default, :install_dir => with_destdir(Gem.dir), :domain => :local, :ignore_dependencies => true +- gemname = Pathname(gem).basename +- puts "#{" "*30}#{gemname}" +- end +- # fix directory permissions +- # TODO: Gem.install should accept :dir_mode option or something +- File.chmod($dir_mode, *Dir.glob(with_destdir(Gem.dir)+"/**/")) +- # fix .gemspec permissions +- File.chmod($data_mode, *Dir.glob(with_destdir(Gem.dir)+"/specifications/*.gemspec")) +- else +- puts "skip installing bundle gems because of lacking zlib" +- end ++ # gems are unbundled in Gentoo. + end + + parse_args() diff --git a/patchsets/patches-2.2.8/001_ia64.patch b/patchsets/patches-2.2.8/001_ia64.patch new file mode 100644 index 0000000..e1e9c89 --- /dev/null +++ b/patchsets/patches-2.2.8/001_ia64.patch @@ -0,0 +1,62 @@ +Bug: https://bugs.gentoo.org/show_bug.cgi?id=561780 + +fix crash on register stack mark/sweep pass + +The crash looks like + + Program received signal SIGSEGV, Segmentation fault. + mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + 3297 v = *x; + (gdb) bt + #0 mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + #1 0x400000000014a040 in gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 + #2 0x400000000014b3a0 in mark_current_machine_context (objspace=0x6000000000045db0, th=0x60000000000455b0) at gc.c:3500 + #3 0x400000000014dfe0 in gc_mark_roots (objspace=0x6000000000045db0, full_mark=0, categoryp=0x0) at gc.c:4105 + #4 0x400000000014e6b0 in gc_marks_body (objspace=0x6000000000045db0, full_mark=0) at gc.c:4164 + #5 0x400000000014f260 in gc_marks (objspace=0x6000000000045db0, full_mark=0) at gc.c:4526 + #6 0x40000000001525c0 in garbage_collect_body (objspace=0x6000000000045db0, full_mark=0, immediate_sweep=0, reason=256) at gc.c:5024 + #7 0x400000000013c010 in heap_prepare_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1219 + #8 0x400000000013c140 in heap_get_freeobj_from_next_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1237 + #9 0x400000000013c360 in heap_get_freeobj (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1259 + #10 0x400000000013c950 in newobj_of (klass=0, flags=40, v1=0, v2=0, v3=0) at gc.c:1303 + #11 0x400000000013ccc0 in rb_newobj_of (klass=0, flags=40) at gc.c:1356 + #12 0x4000000000163740 in hash_alloc (klass=0) at hash.c:289 + #13 0x4000000000163860 in rb_hash_new () at hash.c:309 + #14 0x400000000050e420 in Init_BareVM () at vm.c:2822 + #15 0x40000000000f6b60 in ruby_setup () at eval.c:54 + #16 0x40000000000f6f50 in ruby_init () at eval.c:75 + #17 0x400000000001b010 in main (argc=9, argv=0x60000fffffffb1d8) at main.c:35 + +The problem here is in call + gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 +where 'start' (native_main_thread.register_stack_start) +is supposed to be stack start but it's not initialized. + +The initialization of 'native_main_thread.register_stack_start' +is supposed to be done in 'ruby_init_stack()'. + +But code under 'MAINSTACKADDR_AVAILABLE' exits early. +The fix is to move 'register_stack_start' earlier. + +diff --git a/thread_pthread.c b/thread_pthread.c +index c8a7a16..9ad448b 100644 +--- a/thread_pthread.c ++++ b/thread_pthread.c +@@ -722,2 +722,8 @@ ruby_init_stack(volatile VALUE *addr + native_main_thread.id = pthread_self(); ++#ifdef __ia64 ++ if (!native_main_thread.register_stack_start || ++ (VALUE*)bsp < native_main_thread.register_stack_start) { ++ native_main_thread.register_stack_start = (VALUE*)bsp; ++ } ++#endif + #if MAINSTACKADDR_AVAILABLE +@@ -745,8 +751,2 @@ ruby_init_stack(volatile VALUE *addr + #endif +-#ifdef __ia64 +- if (!native_main_thread.register_stack_start || +- (VALUE*)bsp < native_main_thread.register_stack_start) { +- native_main_thread.register_stack_start = (VALUE*)bsp; +- } +-#endif + { diff --git a/patchsets/patches-2.2.8/004_gfbsd7.patch b/patchsets/patches-2.2.8/004_gfbsd7.patch new file mode 100644 index 0000000..450d714 --- /dev/null +++ b/patchsets/patches-2.2.8/004_gfbsd7.patch @@ -0,0 +1,37 @@ +--- configure.in.orig 2013-05-05 19:36:02.800254192 +0200 ++++ configure.in 2013-05-05 19:37:56.573346196 +0200 +@@ -2156,7 +2156,7 @@ + fi + + AS_CASE(["$target_os"], +-[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl], [ ++[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl | freebsd* | dragonfly*], [ + if test "$rb_cv_binary_elf" = no; then + with_dln_a_out=yes + else +@@ -2249,7 +2249,7 @@ + [bsdi3*], [ AS_CASE(["$CC"], + [*shlicc*], [ : ${LDSHARED='$(CC) -r'} + rb_cv_dlopen=yes])], +- [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ ++ [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | freebsd7*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" +@@ -2262,7 +2262,6 @@ + [freebsd*|dragonfly*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -rdynamic" + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@' + else + test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable' +@@ -2638,7 +2637,7 @@ + [sunos4*], [ + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + ], +- [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu], [ ++ [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu | freebsd7*], [ + LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'" $LDFLAGS_OPTDIR" + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + if test "$load_relative" = yes; then diff --git a/patchsets/patches-2.2.8/005_no-undefined-ext.patch b/patchsets/patches-2.2.8/005_no-undefined-ext.patch new file mode 100644 index 0000000..f279932 --- /dev/null +++ b/patchsets/patches-2.2.8/005_no-undefined-ext.patch @@ -0,0 +1,11 @@ +--- ruby-1.9.3-preview1.orig/configure.in ++++ ruby-1.9.3-preview1/configure.in +@@ -2038,7 +2038,7 @@ if test "$with_dln_a_out" != yes; then + [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -Wl,-export-dynamic" ++ LDFLAGS="$LDFLAGS -Wl,-export-dynamic -Wl,--no-undefined" + fi + rb_cv_dlopen=yes], + [interix*], [ : ${LDSHARED='$(CC) -shared'} diff --git a/patchsets/patches-2.2.8/006_tcltk1.patch b/patchsets/patches-2.2.8/006_tcltk1.patch new file mode 100644 index 0000000..a0e7444 --- /dev/null +++ b/patchsets/patches-2.2.8/006_tcltk1.patch @@ -0,0 +1,27 @@ +From ebd0fc80d62eeb7b8556522256f8d035e013eb65 Mon Sep 17 00:00:00 2001 +From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Sun, 2 Aug 2015 01:27:31 +0000 +Subject: [PATCH] tcltklib.c: check argument + +* ext/tk/tcltklib.c (ip_cancel_eval_core): check argument type and + length. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + ext/tk/tcltklib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c +index afcee3b..e305c13 100644 +--- a/ext/tk/tcltklib.c ++++ b/ext/tk/tcltklib.c +@@ -7745,7 +7745,8 @@ ip_cancel_eval_core(interp, msg, flag) + if (NIL_P(msg)) { + msg_obj = NULL; + } else { +- msg_obj = Tcl_NewStringObj(RSTRING_PTR(msg), RSTRING_LEN(msg)); ++ char *s = StringValuePtr(msg); ++ msg_obj = Tcl_NewStringObj(s, RSTRING_LENINT(msg)); + Tcl_IncrRefCount(msg_obj); + } + diff --git a/patchsets/patches-2.2.8/007_tcltk2.patch b/patchsets/patches-2.2.8/007_tcltk2.patch new file mode 100644 index 0000000..2357898 --- /dev/null +++ b/patchsets/patches-2.2.8/007_tcltk2.patch @@ -0,0 +1,110 @@ +From d098136e3f62a4879a7d7cd34bbd50f482ba3331 Mon Sep 17 00:00:00 2001 +From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Tue, 9 Aug 2016 05:05:11 +0000 +Subject: [PATCH] tcltklib.c: use StringValueCStr [ci skip] + +* ext/tk/tcltklib.c (set_max_block_time, tcl_protect_core, + ip_init, ip_create_slave_core, get_obj_from_str, + ip_cancel_eval_core, lib_set_system_encoding, + alloc_invoke_arguments, lib_merge_tklist): use StringValueCStr + instead of StringValuePtr for values to be passed to Tcl + interperter. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + ext/tk/tcltklib.c | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c +index 430c934..721f497 100644 +--- a/ext/tk/tcltklib.c ++++ b/ext/tk/tcltklib.c +@@ -3303,7 +3303,7 @@ tcl_protect_core(interp, proc, data) /* should not raise exception */ + DUMP1("set backtrace"); + if (!NIL_P(backtrace = rb_funcallv(exc, ID_backtrace, 0, 0))) { + backtrace = rb_ary_join(backtrace, rb_str_new2("\n")); +- Tcl_AddErrorInfo(interp, StringValuePtr(backtrace)); ++ Tcl_AddErrorInfo(interp, StringValueCStr(backtrace)); + } + + rb_thread_critical = thr_crit_bup; +@@ -6208,19 +6208,19 @@ ip_init(argc, argv, self) + /* without Tk */ + with_tk = 0; + } else { +- /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */ +- Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY); ++ /* Tcl_SetVar(ptr->ip, "argv", StringValueCStr(opts), 0); */ ++ Tcl_SetVar(ptr->ip, "argv", StringValueCStr(opts), TCL_GLOBAL_ONLY); + Tcl_Eval(ptr->ip, "set argc [llength $argv]"); + } + case 1: + /* argv0 */ + if (!NIL_P(argv0)) { +- if (strncmp(StringValuePtr(argv0), "-e", 3) == 0 +- || strncmp(StringValuePtr(argv0), "-", 2) == 0) { ++ if (strncmp(StringValueCStr(argv0), "-e", 3) == 0 ++ || strncmp(StringValueCStr(argv0), "-", 2) == 0) { + Tcl_SetVar(ptr->ip, "argv0", "ruby", TCL_GLOBAL_ONLY); + } else { +- /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */ +- Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), ++ /* Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0), 0); */ ++ Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0), + TCL_GLOBAL_ONLY); + } + } +@@ -6420,7 +6420,7 @@ ip_create_slave_core(interp, argc, argv) + slave->allow_ruby_exit = 0; + slave->return_value = 0; + +- slave->ip = Tcl_CreateSlave(master->ip, StringValuePtr(name), safe); ++ slave->ip = Tcl_CreateSlave(master->ip, StringValueCStr(name), safe); + if (slave->ip == NULL) { + rb_thread_critical = thr_crit_bup; + return rb_exc_new2(rb_eRuntimeError, +@@ -6896,7 +6896,7 @@ static Tcl_Obj * + get_obj_from_str(str) + VALUE str; + { +- const char *s = StringValuePtr(str); ++ const char *s = StringValueCStr(str); + + #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 + return Tcl_NewStringObj((char*)s, RSTRING_LEN(str)); +@@ -7744,7 +7744,7 @@ ip_cancel_eval_core(interp, msg, flag) + if (NIL_P(msg)) { + msg_obj = NULL; + } else { +- char *s = StringValuePtr(msg); ++ char *s = StringValueCStr(msg); + msg_obj = Tcl_NewStringObj(s, RSTRING_LENINT(msg)); + Tcl_IncrRefCount(msg_obj); + } +@@ -8409,7 +8409,7 @@ lib_set_system_encoding(self, enc_name) + + enc_name = rb_funcallv(enc_name, ID_to_s, 0, 0); + if (Tcl_SetSystemEncoding((Tcl_Interp *)NULL, +- StringValuePtr(enc_name)) != TCL_OK) { ++ StringValueCStr(enc_name)) != TCL_OK) { + rb_raise(rb_eArgError, "unknown encoding name '%s'", + RSTRING_PTR(enc_name)); + } +@@ -8850,7 +8850,7 @@ alloc_invoke_arguments(argc, argv) + Tcl_Preserve((ClientData)av); /* XXXXXXXX */ + #endif + for (i = 0; i < argc; ++i) { +- av[i] = strdup(StringValuePtr(argv[i])); ++ av[i] = strdup(StringValueCStr(argv[i])); + } + av[argc] = NULL; + #endif +@@ -9854,7 +9854,7 @@ lib_merge_tklist(argc, argv, obj) + len = 1; + for(num = 0; num < argc; num++) { + if (OBJ_TAINTED(argv[num])) taint_flag = 1; +- dst = StringValuePtr(argv[num]); ++ dst = StringValueCStr(argv[num]); + #if TCL_MAJOR_VERSION >= 8 + len += Tcl_ScanCountedElement(dst, RSTRING_LENINT(argv[num]), + &flagPtr[num]) + 1; diff --git a/patchsets/patches-2.2.8/008-net-smtp-validation.patch b/patchsets/patches-2.2.8/008-net-smtp-validation.patch new file mode 100644 index 0000000..0b30c99 --- /dev/null +++ b/patchsets/patches-2.2.8/008-net-smtp-validation.patch @@ -0,0 +1,39 @@ +From 0827a7e52ba3d957a634b063bf5a391239b9ffee Mon Sep 17 00:00:00 2001 +From: shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Wed, 8 Jun 2016 07:06:57 +0000 +Subject: [PATCH] * lib/net/smtp.rb (getok, get_response): raise an + ArgumentError when CR or LF is included in a line, because they are not + allowed in RFC5321. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + lib/net/smtp.rb | 9 +++++++++ + +diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb +index 250293bdbe21..a7130a593b40 100644 +--- a/lib/net/smtp.rb ++++ b/lib/net/smtp.rb +@@ -926,7 +926,15 @@ def quit + + private + ++ def validate_line(line) ++ # A bare CR or LF is not allowed in RFC5321. ++ if /[\r\n]/ =~ line ++ raise ArgumentError, "A line must not contain CR or LF" ++ end ++ end ++ + def getok(reqline) ++ validate_line reqline + res = critical { + @socket.writeline reqline + recv_response() +@@ -936,6 +944,7 @@ def getok(reqline) + end + + def get_response(reqline) ++ validate_line reqline + @socket.writeline reqline + recv_response() + end diff --git a/patchsets/patches-2.2.8/009_no-gems.patch b/patchsets/patches-2.2.8/009_no-gems.patch new file mode 100644 index 0000000..a67cbf8 --- /dev/null +++ b/patchsets/patches-2.2.8/009_no-gems.patch @@ -0,0 +1,88 @@ +--- tool/rbinstall.rb.~1~ 2015-03-25 04:33:14.000000000 +0100 ++++ tool/rbinstall.rb 2015-04-14 07:07:01.169073427 +0200 +@@ -654,83 +654,11 @@ + # :startdoc: + + install?(:ext, :comm, :gem) do +- $:.unshift(File.join(srcdir, "lib")) +- require("rubygems.rb") +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "default gems", gem_dir, directories +- +- spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0]) +- default_spec_dir = "#{spec_dir}/default" +- makedirs(default_spec_dir) +- +- gems = {} +- File.foreach(File.join(srcdir, "defs/default_gems")) do |line| +- line.chomp! +- line.sub!(/\s*#.*/, '') +- next if line.empty? +- words = [] +- line.scan(/\G\s*([^\[\]\s]+|\[([^\[\]]*)\])/) do +- words << ($2 ? $2.split : $1) +- end +- name, base_dir, src, execs = *words +- next unless name and base_dir and src +- +- src = File.join(srcdir, src) +- base_dir = File.join(srcdir, base_dir) +- specgen = RbInstall::Specs::Generator.new(name, base_dir, src, execs || []) +- gems[name] ||= specgen +- end +- +- Dir.glob(srcdir+"/{lib,ext}/**/*.gemspec").each do |src| +- specgen = RbInstall::Specs::Reader.new(src) +- gems[specgen.gemspec.name] ||= specgen +- end +- +- gems.sort.each do |name, specgen| +- gemspec = specgen.gemspec +- base_dir = specgen.src.sub(/\A#{Regexp.escape(srcdir)}\//, "") +- full_name = "#{gemspec.name}-#{gemspec.version}" +- +- puts "#{" "*30}#{gemspec.name} #{gemspec.version}" +- gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec") +- open_for_install(gemspec_path, $data_mode) do +- specgen.spec_source +- end +- +- unless gemspec.executables.empty? then +- bin_dir = File.join(gem_dir, 'gems', full_name, 'bin') +- makedirs(bin_dir) +- +- execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)} +- install(execs, bin_dir, :mode => $prog_mode) +- end +- end ++ # gems are unbundled in Gentoo. + end + + install?(:ext, :comm, :gem) do +- begin +- require "zlib" +- rescue LoadError +- end +- if defined?(Zlib) +- require 'pathname' +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "bundle gems", gem_dir, directories +- Dir.glob(srcdir+'/gems/*.gem').each do |gem| +- Gem.install gem, Gem::Requirement.default, :install_dir => with_destdir(Gem.dir), :domain => :local, :ignore_dependencies => true +- gemname = Pathname(gem).basename +- puts "#{" "*30}#{gemname}" +- end +- # fix directory permissions +- # TODO: Gem.install should accept :dir_mode option or something +- File.chmod($dir_mode, *Dir.glob(with_destdir(Gem.dir)+"/**/")) +- # fix .gemspec permissions +- File.chmod($data_mode, *Dir.glob(with_destdir(Gem.dir)+"/specifications/*.gemspec")) +- else +- puts "skip installing bundle gems because of lacking zlib" +- end ++ # gems are unbundled in Gentoo. + end + + parse_args() diff --git a/patchsets/patches-2.3.4-r4/001_ia64.patch b/patchsets/patches-2.3.4-r4/001_ia64.patch new file mode 100644 index 0000000..e1e9c89 --- /dev/null +++ b/patchsets/patches-2.3.4-r4/001_ia64.patch @@ -0,0 +1,62 @@ +Bug: https://bugs.gentoo.org/show_bug.cgi?id=561780 + +fix crash on register stack mark/sweep pass + +The crash looks like + + Program received signal SIGSEGV, Segmentation fault. + mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + 3297 v = *x; + (gdb) bt + #0 mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + #1 0x400000000014a040 in gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 + #2 0x400000000014b3a0 in mark_current_machine_context (objspace=0x6000000000045db0, th=0x60000000000455b0) at gc.c:3500 + #3 0x400000000014dfe0 in gc_mark_roots (objspace=0x6000000000045db0, full_mark=0, categoryp=0x0) at gc.c:4105 + #4 0x400000000014e6b0 in gc_marks_body (objspace=0x6000000000045db0, full_mark=0) at gc.c:4164 + #5 0x400000000014f260 in gc_marks (objspace=0x6000000000045db0, full_mark=0) at gc.c:4526 + #6 0x40000000001525c0 in garbage_collect_body (objspace=0x6000000000045db0, full_mark=0, immediate_sweep=0, reason=256) at gc.c:5024 + #7 0x400000000013c010 in heap_prepare_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1219 + #8 0x400000000013c140 in heap_get_freeobj_from_next_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1237 + #9 0x400000000013c360 in heap_get_freeobj (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1259 + #10 0x400000000013c950 in newobj_of (klass=0, flags=40, v1=0, v2=0, v3=0) at gc.c:1303 + #11 0x400000000013ccc0 in rb_newobj_of (klass=0, flags=40) at gc.c:1356 + #12 0x4000000000163740 in hash_alloc (klass=0) at hash.c:289 + #13 0x4000000000163860 in rb_hash_new () at hash.c:309 + #14 0x400000000050e420 in Init_BareVM () at vm.c:2822 + #15 0x40000000000f6b60 in ruby_setup () at eval.c:54 + #16 0x40000000000f6f50 in ruby_init () at eval.c:75 + #17 0x400000000001b010 in main (argc=9, argv=0x60000fffffffb1d8) at main.c:35 + +The problem here is in call + gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 +where 'start' (native_main_thread.register_stack_start) +is supposed to be stack start but it's not initialized. + +The initialization of 'native_main_thread.register_stack_start' +is supposed to be done in 'ruby_init_stack()'. + +But code under 'MAINSTACKADDR_AVAILABLE' exits early. +The fix is to move 'register_stack_start' earlier. + +diff --git a/thread_pthread.c b/thread_pthread.c +index c8a7a16..9ad448b 100644 +--- a/thread_pthread.c ++++ b/thread_pthread.c +@@ -722,2 +722,8 @@ ruby_init_stack(volatile VALUE *addr + native_main_thread.id = pthread_self(); ++#ifdef __ia64 ++ if (!native_main_thread.register_stack_start || ++ (VALUE*)bsp < native_main_thread.register_stack_start) { ++ native_main_thread.register_stack_start = (VALUE*)bsp; ++ } ++#endif + #if MAINSTACKADDR_AVAILABLE +@@ -745,8 +751,2 @@ ruby_init_stack(volatile VALUE *addr + #endif +-#ifdef __ia64 +- if (!native_main_thread.register_stack_start || +- (VALUE*)bsp < native_main_thread.register_stack_start) { +- native_main_thread.register_stack_start = (VALUE*)bsp; +- } +-#endif + { diff --git a/patchsets/patches-2.3.4-r4/002_json-heap-exposure.patch b/patchsets/patches-2.3.4-r4/002_json-heap-exposure.patch new file mode 100644 index 0000000..6176caa --- /dev/null +++ b/patchsets/patches-2.3.4-r4/002_json-heap-exposure.patch @@ -0,0 +1,83 @@ +diff --git ext/json/generator/generator.c ext/json/generator/generator.c +index a135e28348..2cdca5685f 100644 +--- ext/json/generator/generator.c ++++ ext/json/generator/generator.c +@@ -301,7 +301,7 @@ static char *fstrndup(const char *ptr, unsigned long len) { + char *result; + if (len <= 0) return NULL; + result = ALLOC_N(char, len); +- memccpy(result, ptr, 0, len); ++ memcpy(result, ptr, len); + return result; + } + +@@ -1055,7 +1055,7 @@ static VALUE cState_indent_set(VALUE self, VALUE indent) + } + } else { + if (state->indent) ruby_xfree(state->indent); +- state->indent = strdup(RSTRING_PTR(indent)); ++ state->indent = fstrndup(RSTRING_PTR(indent), len); + state->indent_len = len; + } + return Qnil; +@@ -1093,7 +1093,7 @@ static VALUE cState_space_set(VALUE self, VALUE space) + } + } else { + if (state->space) ruby_xfree(state->space); +- state->space = strdup(RSTRING_PTR(space)); ++ state->space = fstrndup(RSTRING_PTR(space), len); + state->space_len = len; + } + return Qnil; +@@ -1129,7 +1129,7 @@ static VALUE cState_space_before_set(VALUE self, VALUE space_before) + } + } else { + if (state->space_before) ruby_xfree(state->space_before); +- state->space_before = strdup(RSTRING_PTR(space_before)); ++ state->space_before = fstrndup(RSTRING_PTR(space_before), len); + state->space_before_len = len; + } + return Qnil; +@@ -1166,7 +1166,7 @@ static VALUE cState_object_nl_set(VALUE self, VALUE object_nl) + } + } else { + if (state->object_nl) ruby_xfree(state->object_nl); +- state->object_nl = strdup(RSTRING_PTR(object_nl)); ++ state->object_nl = fstrndup(RSTRING_PTR(object_nl), len); + state->object_nl_len = len; + } + return Qnil; +@@ -1201,7 +1201,7 @@ static VALUE cState_array_nl_set(VALUE self, VALUE array_nl) + } + } else { + if (state->array_nl) ruby_xfree(state->array_nl); +- state->array_nl = strdup(RSTRING_PTR(array_nl)); ++ state->array_nl = fstrndup(RSTRING_PTR(array_nl), len); + state->array_nl_len = len; + } + return Qnil; +diff --git ext/json/generator/generator.h ext/json/generator/generator.h +index 298c0a4965..6bbf817b7d 100644 +--- ext/json/generator/generator.h ++++ ext/json/generator/generator.h +@@ -1,7 +1,6 @@ + #ifndef _GENERATOR_H_ + #define _GENERATOR_H_ + +-#include <string.h> + #include <math.h> + #include <ctype.h> + +diff --git ext/json/lib/json/version.rb ext/json/lib/json/version.rb +index b5748334b9..cd7ddf8777 100644 +--- ext/json/lib/json/version.rb ++++ ext/json/lib/json/version.rb +@@ -1,7 +1,7 @@ + # frozen_string_literal: false + module JSON + # JSON version +- VERSION = '1.8.3' ++ VERSION = '1.8.3.1' + VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: + VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: + VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: diff --git a/patchsets/patches-2.3.4-r4/004_gfbsd7.patch b/patchsets/patches-2.3.4-r4/004_gfbsd7.patch new file mode 100644 index 0000000..fa561b6 --- /dev/null +++ b/patchsets/patches-2.3.4-r4/004_gfbsd7.patch @@ -0,0 +1,37 @@ +--- configure.in.orig 2013-05-05 19:36:02.800254192 +0200 ++++ configure.in 2013-05-05 19:37:56.573346196 +0200 +@@ -2156,7 +2156,7 @@ + fi + + AS_CASE(["$target_os"], +-[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl], [ ++[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl | freebsd* | dragonfly*], [ + if test "$rb_cv_binary_elf" = no; then + with_dln_a_out=yes + else +@@ -2249,7 +2249,7 @@ + [bsdi3*], [ AS_CASE(["$CC"], + [*shlicc*], [ : ${LDSHARED='$(CC) -r'} + rb_cv_dlopen=yes])], +- [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | haiku*], [ ++ [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | haiku* | freebsd7*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" +@@ -2262,7 +2262,6 @@ + [freebsd*|dragonfly*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -rdynamic" + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@' + else + test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable' +@@ -2638,7 +2637,7 @@ + [sunos4*], [ + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + ], +- [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu | haiku*], [ ++ [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu | haiku* | freebsd7*], [ + LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'" $LDFLAGS_OPTDIR" + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + if test "$load_relative" = yes; then diff --git a/patchsets/patches-2.3.4-r4/005_no-undefined-ext.patch b/patchsets/patches-2.3.4-r4/005_no-undefined-ext.patch new file mode 100644 index 0000000..f279932 --- /dev/null +++ b/patchsets/patches-2.3.4-r4/005_no-undefined-ext.patch @@ -0,0 +1,11 @@ +--- ruby-1.9.3-preview1.orig/configure.in ++++ ruby-1.9.3-preview1/configure.in +@@ -2038,7 +2038,7 @@ if test "$with_dln_a_out" != yes; then + [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -Wl,-export-dynamic" ++ LDFLAGS="$LDFLAGS -Wl,-export-dynamic -Wl,--no-undefined" + fi + rb_cv_dlopen=yes], + [interix*], [ : ${LDSHARED='$(CC) -shared'} diff --git a/patchsets/patches-2.3.4-r4/007-openssl-weakdh.patch b/patchsets/patches-2.3.4-r4/007-openssl-weakdh.patch new file mode 100644 index 0000000..ca41065 --- /dev/null +++ b/patchsets/patches-2.3.4-r4/007-openssl-weakdh.patch @@ -0,0 +1,37 @@ +From 6dee08d14f7a8a51691b799592774e805d6f8707 Mon Sep 17 00:00:00 2001 +From: Tony Arcieri <bascule@gmail.com> +Date: Thu, 7 Jan 2016 11:02:31 -0800 +Subject: [PATCH] Remove 512-bit DH group + +512-bit DH keys are severely weak and have been implicated in recent attacks: + +https://weakdh.org/ +--- + lib/openssl/pkey.rb | 8 -------- + +diff --git a/lib/openssl/pkey.rb b/lib/openssl/pkey.rb +index 3f65adad..89563b65 100644 +--- a/ext/openssl/lib/openssl/pkey.rb ++++ b/ext/openssl/lib/openssl/pkey.rb +@@ -4,13 +4,6 @@ module PKey + if defined?(OpenSSL::PKey::DH) + + class DH +- DEFAULT_512 = new <<-_end_of_pem_ +------BEGIN DH PARAMETERS----- +-MEYCQQD0zXHljRg/mJ9PYLACLv58Cd8VxBxxY7oEuCeURMiTqEhMym16rhhKgZG2 +-zk2O9uUIBIxSj+NKMURHGaFKyIvLAgEC +------END DH PARAMETERS----- +- _end_of_pem_ +- + DEFAULT_1024 = new <<-_end_of_pem_ + -----BEGIN DH PARAMETERS----- + MIGHAoGBAJ0lOVy0VIr/JebWn0zDwY2h+rqITFOpdNr6ugsgvkDXuucdcChhYExJ +@@ -23,7 +16,6 @@ class DH + DEFAULT_TMP_DH_CALLBACK = lambda { |ctx, is_export, keylen| + warn "using default DH parameters." if $VERBOSE + case keylen +- when 512 then OpenSSL::PKey::DH::DEFAULT_512 + when 1024 then OpenSSL::PKey::DH::DEFAULT_1024 + else + nil diff --git a/patchsets/patches-2.3.4-r4/008-net-smtp-validation.patch b/patchsets/patches-2.3.4-r4/008-net-smtp-validation.patch new file mode 100644 index 0000000..0b30c99 --- /dev/null +++ b/patchsets/patches-2.3.4-r4/008-net-smtp-validation.patch @@ -0,0 +1,39 @@ +From 0827a7e52ba3d957a634b063bf5a391239b9ffee Mon Sep 17 00:00:00 2001 +From: shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Wed, 8 Jun 2016 07:06:57 +0000 +Subject: [PATCH] * lib/net/smtp.rb (getok, get_response): raise an + ArgumentError when CR or LF is included in a line, because they are not + allowed in RFC5321. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + lib/net/smtp.rb | 9 +++++++++ + +diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb +index 250293bdbe21..a7130a593b40 100644 +--- a/lib/net/smtp.rb ++++ b/lib/net/smtp.rb +@@ -926,7 +926,15 @@ def quit + + private + ++ def validate_line(line) ++ # A bare CR or LF is not allowed in RFC5321. ++ if /[\r\n]/ =~ line ++ raise ArgumentError, "A line must not contain CR or LF" ++ end ++ end ++ + def getok(reqline) ++ validate_line reqline + res = critical { + @socket.writeline reqline + recv_response() +@@ -936,6 +944,7 @@ def getok(reqline) + end + + def get_response(reqline) ++ validate_line reqline + @socket.writeline reqline + recv_response() + end diff --git a/patchsets/patches-2.3.4-r4/009_no-gems.patch b/patchsets/patches-2.3.4-r4/009_no-gems.patch new file mode 100644 index 0000000..2da6b7d --- /dev/null +++ b/patchsets/patches-2.3.4-r4/009_no-gems.patch @@ -0,0 +1,95 @@ +--- tool/rbinstall.rb.~1~ 2017-03-27 17:18:38.000000000 +0200 ++++ tool/rbinstall.rb 2017-03-30 07:38:53.437332083 +0200 +@@ -696,90 +696,11 @@ + # :startdoc: + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "default gems", gem_dir, directories +- +- spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0]) +- default_spec_dir = "#{spec_dir}/default" +- makedirs(default_spec_dir) +- +- gems = {} +- +- Dir.glob(srcdir+"/{lib,ext}/**/*.gemspec").each do |src| +- specgen = RbInstall::Specs::Reader.new(src) +- gems[specgen.gemspec.name] ||= specgen +- end +- +- gems.sort.each do |name, specgen| +- gemspec = specgen.gemspec +- full_name = "#{gemspec.name}-#{gemspec.version}" +- +- puts "#{" "*30}#{gemspec.name} #{gemspec.version}" +- gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec") +- open_for_install(gemspec_path, $data_mode) do +- specgen.spec_source +- end +- +- unless gemspec.executables.empty? then +- bin_dir = File.join(gem_dir, 'gems', full_name, 'bin') +- makedirs(bin_dir) +- +- execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)} +- install(execs, bin_dir, :mode => $script_mode) +- end +- end ++ # gems are unbundled in Gentoo + end + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "bundle gems", gem_dir, directories +- install_dir = with_destdir(gem_dir) +- installed_gems = {} +- options = { +- :install_dir => install_dir, +- :bin_dir => with_destdir(bindir), +- :domain => :local, +- :ignore_dependencies => true, +- :dir_mode => $dir_mode, +- :data_mode => $data_mode, +- :prog_mode => $prog_mode, +- :wrappers => true, +- :format_executable => true, +- } +- Gem::Specification.each_spec([srcdir+'/gems/*']) do |spec| +- ins = RbInstall::UnpackedInstaller.new(spec, options) +- puts "#{" "*30}#{spec.name} #{spec.version}" +- ins.install +- File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec")) +- installed_gems[spec.full_name] = true +- end +- installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))} +- unless installed_gems.empty? +- install installed_gems, gem_dir+"/cache" +- end +- next if gems.empty? +- if defined?(Zlib) +- Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name))) +- gems.each do |gem| +- begin +- File.umask(022) +- Gem.install(gem, Gem::Requirement.default, options) +- ensure +- File.umask(0222) +- end +- gemname = File.basename(gem) +- puts "#{" "*30}#{gemname}" +- end +- # fix directory permissions +- # TODO: Gem.install should accept :dir_mode option or something +- File.chmod($dir_mode, *Dir.glob(install_dir+"/**/")) +- # fix .gemspec permissions +- File.chmod($data_mode, *Dir.glob(install_dir+"/specifications/*.gemspec")) +- else +- puts "skip installing bundle gems because of lacking zlib" +- end ++ # gems are unbundled in Gentoo + end + + parse_args() diff --git a/patchsets/patches-2.3.5/001_jemalloc-libgmp.patch b/patchsets/patches-2.3.5/001_jemalloc-libgmp.patch new file mode 100644 index 0000000..e6bfa12 --- /dev/null +++ b/patchsets/patches-2.3.5/001_jemalloc-libgmp.patch @@ -0,0 +1,40 @@ +diff -pU3 a/configure b/configure +--- a/configure 2017-09-14 21:09:29.000000000 +0900 ++++ b/configure 2017-09-15 05:56:46.000000000 +0900 +@@ -10366,6 +10366,7 @@ fi + ac_res=$ac_cv_search___gmpz_init + if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ++ $as_echo "#define HAVE_LIBGMP 1" >>confdefs.h + + fi + +@@ -10435,6 +10436,7 @@ fi + ac_res=$ac_cv_search_malloc_conf + if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ++ $as_echo "#define HAVE_LIBJEMALLOC 1" >>confdefs.h + + else + with_jemalloc=no +diff -pU3 a/configure.in b/configure.in +--- a/configure.in 2017-08-09 19:28:56.000000000 +0900 ++++ b/configure.in 2017-09-15 07:18:25.000000000 +0900 +@@ -1337,13 +1337,15 @@ AC_ARG_WITH([gmp], + AS_IF([test "x$with_gmp" != xno], + [AC_CHECK_HEADERS(gmp.h) + AS_IF([test "x$ac_cv_header_gmp_h" != xno], +- AC_SEARCH_LIBS([__gmpz_init], [gmp]))]) ++ AC_SEARCH_LIBS([__gmpz_init], [gmp], ++ [AC_DEFINE(HAVE_LIBGMP, 1)]))]) + + AC_ARG_WITH([jemalloc], + [AS_HELP_STRING([--with-jemalloc],[use jemalloc allocator])], + [with_jemalloc=$withval], [with_jemalloc=no]) + AS_IF([test "x$with_jemalloc" = xyes],[ +- AC_SEARCH_LIBS([malloc_conf], [jemalloc], [], [with_jemalloc=no]) ++ AC_SEARCH_LIBS([malloc_conf], [jemalloc], ++ [AC_DEFINE(HAVE_LIBJEMALLOC, 1)], [with_jemalloc=no]) + AC_CHECK_HEADER(jemalloc/jemalloc.h, [ + AC_DEFINE(RUBY_ALTERNATIVE_MALLOC_HEADER, [<jemalloc/jemalloc.h>]) + ]) diff --git a/patchsets/patches-2.3.5/004_gfbsd7.patch b/patchsets/patches-2.3.5/004_gfbsd7.patch new file mode 100644 index 0000000..fa561b6 --- /dev/null +++ b/patchsets/patches-2.3.5/004_gfbsd7.patch @@ -0,0 +1,37 @@ +--- configure.in.orig 2013-05-05 19:36:02.800254192 +0200 ++++ configure.in 2013-05-05 19:37:56.573346196 +0200 +@@ -2156,7 +2156,7 @@ + fi + + AS_CASE(["$target_os"], +-[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl], [ ++[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl | freebsd* | dragonfly*], [ + if test "$rb_cv_binary_elf" = no; then + with_dln_a_out=yes + else +@@ -2249,7 +2249,7 @@ + [bsdi3*], [ AS_CASE(["$CC"], + [*shlicc*], [ : ${LDSHARED='$(CC) -r'} + rb_cv_dlopen=yes])], +- [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | haiku*], [ ++ [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu | haiku* | freebsd7*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" +@@ -2262,7 +2262,6 @@ + [freebsd*|dragonfly*], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -rdynamic" + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@' + else + test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable' +@@ -2638,7 +2637,7 @@ + [sunos4*], [ + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + ], +- [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu | haiku*], [ ++ [linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu | haiku* | freebsd7*], [ + LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'" $LDFLAGS_OPTDIR" + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' + if test "$load_relative" = yes; then diff --git a/patchsets/patches-2.3.5/005_no-undefined-ext.patch b/patchsets/patches-2.3.5/005_no-undefined-ext.patch new file mode 100644 index 0000000..f279932 --- /dev/null +++ b/patchsets/patches-2.3.5/005_no-undefined-ext.patch @@ -0,0 +1,11 @@ +--- ruby-1.9.3-preview1.orig/configure.in ++++ ruby-1.9.3-preview1/configure.in +@@ -2038,7 +2038,7 @@ if test "$with_dln_a_out" != yes; then + [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -Wl,-export-dynamic" ++ LDFLAGS="$LDFLAGS -Wl,-export-dynamic -Wl,--no-undefined" + fi + rb_cv_dlopen=yes], + [interix*], [ : ${LDSHARED='$(CC) -shared'} diff --git a/patchsets/patches-2.3.5/007-openssl-weakdh.patch b/patchsets/patches-2.3.5/007-openssl-weakdh.patch new file mode 100644 index 0000000..ca41065 --- /dev/null +++ b/patchsets/patches-2.3.5/007-openssl-weakdh.patch @@ -0,0 +1,37 @@ +From 6dee08d14f7a8a51691b799592774e805d6f8707 Mon Sep 17 00:00:00 2001 +From: Tony Arcieri <bascule@gmail.com> +Date: Thu, 7 Jan 2016 11:02:31 -0800 +Subject: [PATCH] Remove 512-bit DH group + +512-bit DH keys are severely weak and have been implicated in recent attacks: + +https://weakdh.org/ +--- + lib/openssl/pkey.rb | 8 -------- + +diff --git a/lib/openssl/pkey.rb b/lib/openssl/pkey.rb +index 3f65adad..89563b65 100644 +--- a/ext/openssl/lib/openssl/pkey.rb ++++ b/ext/openssl/lib/openssl/pkey.rb +@@ -4,13 +4,6 @@ module PKey + if defined?(OpenSSL::PKey::DH) + + class DH +- DEFAULT_512 = new <<-_end_of_pem_ +------BEGIN DH PARAMETERS----- +-MEYCQQD0zXHljRg/mJ9PYLACLv58Cd8VxBxxY7oEuCeURMiTqEhMym16rhhKgZG2 +-zk2O9uUIBIxSj+NKMURHGaFKyIvLAgEC +------END DH PARAMETERS----- +- _end_of_pem_ +- + DEFAULT_1024 = new <<-_end_of_pem_ + -----BEGIN DH PARAMETERS----- + MIGHAoGBAJ0lOVy0VIr/JebWn0zDwY2h+rqITFOpdNr6ugsgvkDXuucdcChhYExJ +@@ -23,7 +16,6 @@ class DH + DEFAULT_TMP_DH_CALLBACK = lambda { |ctx, is_export, keylen| + warn "using default DH parameters." if $VERBOSE + case keylen +- when 512 then OpenSSL::PKey::DH::DEFAULT_512 + when 1024 then OpenSSL::PKey::DH::DEFAULT_1024 + else + nil diff --git a/patchsets/patches-2.3.5/009_no-gems.patch b/patchsets/patches-2.3.5/009_no-gems.patch new file mode 100644 index 0000000..2da6b7d --- /dev/null +++ b/patchsets/patches-2.3.5/009_no-gems.patch @@ -0,0 +1,95 @@ +--- tool/rbinstall.rb.~1~ 2017-03-27 17:18:38.000000000 +0200 ++++ tool/rbinstall.rb 2017-03-30 07:38:53.437332083 +0200 +@@ -696,90 +696,11 @@ + # :startdoc: + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "default gems", gem_dir, directories +- +- spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0]) +- default_spec_dir = "#{spec_dir}/default" +- makedirs(default_spec_dir) +- +- gems = {} +- +- Dir.glob(srcdir+"/{lib,ext}/**/*.gemspec").each do |src| +- specgen = RbInstall::Specs::Reader.new(src) +- gems[specgen.gemspec.name] ||= specgen +- end +- +- gems.sort.each do |name, specgen| +- gemspec = specgen.gemspec +- full_name = "#{gemspec.name}-#{gemspec.version}" +- +- puts "#{" "*30}#{gemspec.name} #{gemspec.version}" +- gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec") +- open_for_install(gemspec_path, $data_mode) do +- specgen.spec_source +- end +- +- unless gemspec.executables.empty? then +- bin_dir = File.join(gem_dir, 'gems', full_name, 'bin') +- makedirs(bin_dir) +- +- execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)} +- install(execs, bin_dir, :mode => $script_mode) +- end +- end ++ # gems are unbundled in Gentoo + end + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "bundle gems", gem_dir, directories +- install_dir = with_destdir(gem_dir) +- installed_gems = {} +- options = { +- :install_dir => install_dir, +- :bin_dir => with_destdir(bindir), +- :domain => :local, +- :ignore_dependencies => true, +- :dir_mode => $dir_mode, +- :data_mode => $data_mode, +- :prog_mode => $prog_mode, +- :wrappers => true, +- :format_executable => true, +- } +- Gem::Specification.each_spec([srcdir+'/gems/*']) do |spec| +- ins = RbInstall::UnpackedInstaller.new(spec, options) +- puts "#{" "*30}#{spec.name} #{spec.version}" +- ins.install +- File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec")) +- installed_gems[spec.full_name] = true +- end +- installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))} +- unless installed_gems.empty? +- install installed_gems, gem_dir+"/cache" +- end +- next if gems.empty? +- if defined?(Zlib) +- Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name))) +- gems.each do |gem| +- begin +- File.umask(022) +- Gem.install(gem, Gem::Requirement.default, options) +- ensure +- File.umask(0222) +- end +- gemname = File.basename(gem) +- puts "#{" "*30}#{gemname}" +- end +- # fix directory permissions +- # TODO: Gem.install should accept :dir_mode option or something +- File.chmod($dir_mode, *Dir.glob(install_dir+"/**/")) +- # fix .gemspec permissions +- File.chmod($data_mode, *Dir.glob(install_dir+"/specifications/*.gemspec")) +- else +- puts "skip installing bundle gems because of lacking zlib" +- end ++ # gems are unbundled in Gentoo + end + + parse_args() diff --git a/patchsets/patches-2.4.1-r4/001_ia64.patch b/patchsets/patches-2.4.1-r4/001_ia64.patch new file mode 100644 index 0000000..e1e9c89 --- /dev/null +++ b/patchsets/patches-2.4.1-r4/001_ia64.patch @@ -0,0 +1,62 @@ +Bug: https://bugs.gentoo.org/show_bug.cgi?id=561780 + +fix crash on register stack mark/sweep pass + +The crash looks like + + Program received signal SIGSEGV, Segmentation fault. + mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + 3297 v = *x; + (gdb) bt + #0 mark_locations_array (objspace=0x6000000000045db0, x=0x0, n=864692227966763116) at gc.c:3297 + #1 0x400000000014a040 in gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 + #2 0x400000000014b3a0 in mark_current_machine_context (objspace=0x6000000000045db0, th=0x60000000000455b0) at gc.c:3500 + #3 0x400000000014dfe0 in gc_mark_roots (objspace=0x6000000000045db0, full_mark=0, categoryp=0x0) at gc.c:4105 + #4 0x400000000014e6b0 in gc_marks_body (objspace=0x6000000000045db0, full_mark=0) at gc.c:4164 + #5 0x400000000014f260 in gc_marks (objspace=0x6000000000045db0, full_mark=0) at gc.c:4526 + #6 0x40000000001525c0 in garbage_collect_body (objspace=0x6000000000045db0, full_mark=0, immediate_sweep=0, reason=256) at gc.c:5024 + #7 0x400000000013c010 in heap_prepare_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1219 + #8 0x400000000013c140 in heap_get_freeobj_from_next_freepage (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1237 + #9 0x400000000013c360 in heap_get_freeobj (objspace=0x6000000000045db0, heap=0x6000000000045dc0) at gc.c:1259 + #10 0x400000000013c950 in newobj_of (klass=0, flags=40, v1=0, v2=0, v3=0) at gc.c:1303 + #11 0x400000000013ccc0 in rb_newobj_of (klass=0, flags=40) at gc.c:1356 + #12 0x4000000000163740 in hash_alloc (klass=0) at hash.c:289 + #13 0x4000000000163860 in rb_hash_new () at hash.c:309 + #14 0x400000000050e420 in Init_BareVM () at vm.c:2822 + #15 0x40000000000f6b60 in ruby_setup () at eval.c:54 + #16 0x40000000000f6f50 in ruby_init () at eval.c:75 + #17 0x400000000001b010 in main (argc=9, argv=0x60000fffffffb1d8) at main.c:35 + +The problem here is in call + gc_mark_locations (objspace=0x6000000000045db0, start=0x0, end=0x6000080000000368) at gc.c:3310 +where 'start' (native_main_thread.register_stack_start) +is supposed to be stack start but it's not initialized. + +The initialization of 'native_main_thread.register_stack_start' +is supposed to be done in 'ruby_init_stack()'. + +But code under 'MAINSTACKADDR_AVAILABLE' exits early. +The fix is to move 'register_stack_start' earlier. + +diff --git a/thread_pthread.c b/thread_pthread.c +index c8a7a16..9ad448b 100644 +--- a/thread_pthread.c ++++ b/thread_pthread.c +@@ -722,2 +722,8 @@ ruby_init_stack(volatile VALUE *addr + native_main_thread.id = pthread_self(); ++#ifdef __ia64 ++ if (!native_main_thread.register_stack_start || ++ (VALUE*)bsp < native_main_thread.register_stack_start) { ++ native_main_thread.register_stack_start = (VALUE*)bsp; ++ } ++#endif + #if MAINSTACKADDR_AVAILABLE +@@ -745,8 +751,2 @@ ruby_init_stack(volatile VALUE *addr + #endif +-#ifdef __ia64 +- if (!native_main_thread.register_stack_start || +- (VALUE*)bsp < native_main_thread.register_stack_start) { +- native_main_thread.register_stack_start = (VALUE*)bsp; +- } +-#endif + { diff --git a/patchsets/patches-2.4.1-r4/002_windows_crossdev.patch b/patchsets/patches-2.4.1-r4/002_windows_crossdev.patch new file mode 100644 index 0000000..7e290d4 --- /dev/null +++ b/patchsets/patches-2.4.1-r4/002_windows_crossdev.patch @@ -0,0 +1,64 @@ +Bug: https://bugs.gentoo.org/show_bug.cgi?id=618878 + +A few patches to make crossdev for mingw-w64 play nice with ruby's ebuilds. +Basic gist is that without the following patch to configure.in ruby-2.4.1 +hardcodes 240 into the shared, static, and import library names, which when +built with the current ruby ebuilds results in names like libx64-msvcrt-ruby24240.dll and so on. The patch is in ruby-trunk[1], but may take a while +to hit the tarballs that gentoo uses. + +Index: configure.in +=================================================================== +--- a/configure.in (revision 57824) ++++ b/configure.in (revision 57825) +@@ -3825,7 +3825,23 @@ + + AC_ARG_WITH(soname, + AS_HELP_STRING([--with-soname=SONAME], [base name of shared library]), +- [RUBY_SO_NAME=$withval], [RUBY_SO_NAME='$(RUBY_BASE_NAME)']) ++ [RUBY_SO_NAME=$withval], ++ [ ++ AS_CASE(["$target_os"], ++ [darwin*], [ ++ RUBY_SO_NAME='$(RUBY_BASE_NAME).$(RUBY_PROGRAM_VERSION)' ++ ], ++ [cygwin*], [ ++ RUBY_SO_NAME='$(RUBY_BASE_NAME)$(MAJOR)$(MINOR)0' ++ ], ++ [mingw*], [ ++ RUBY_SO_NAME="${rb_cv_msvcrt}"'-$(RUBY_BASE_NAME)$(MAJOR)$(MINOR)0' ++ AS_IF([test x"${target_cpu}" != xi386], [ ++ RUBY_SO_NAME="${target_cpu}-${RUBY_SO_NAME}" ++ ]) ++ ], ++ [RUBY_SO_NAME='$(RUBY_BASE_NAME)']) ++ ]) + + LIBRUBY_LDSHARED=$LDSHARED + LIBRUBY_DLDFLAGS=$DLDFLAGS +@@ -3925,7 +3941,6 @@ + SOLIBS='-lm -lc' + ], + [darwin*], [ +- RUBY_SO_NAME="$RUBY_SO_NAME"'.$(RUBY_PROGRAM_VERSION)' + LIBRUBY_LDSHARED='$(CC) -dynamiclib' + if test "$load_relative" = yes; then + libprefix="@executable_path/../${libdir_basename}" +@@ -4157,7 +4172,6 @@ + fi + ], + [cygwin*|mingw*], [ +- RUBY_SO_NAME="${RUBY_SO_NAME}"'$(MAJOR)$(MINOR)0' + LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)' + AS_CASE(["$target_os"], + [cygwin*], [ +@@ -4167,10 +4181,6 @@ + fi + ], + [mingw*], [ +- RUBY_SO_NAME="${rb_cv_msvcrt}-${RUBY_SO_NAME}" +- if test x"${target_cpu}" != xi386; then +- RUBY_SO_NAME="${target_cpu}-${RUBY_SO_NAME}" +- fi + if test x"$enable_shared" = xyes; then + LIBRUBY_SO='$(RUBY_SO_NAME)'.dll + LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' $(RUBYDEF)' diff --git a/patchsets/patches-2.4.1-r4/003_json-heap-exposure.patch b/patchsets/patches-2.4.1-r4/003_json-heap-exposure.patch new file mode 100644 index 0000000..98c592a --- /dev/null +++ b/patchsets/patches-2.4.1-r4/003_json-heap-exposure.patch @@ -0,0 +1,83 @@ +diff --git ext/json/generator/generator.c ext/json/generator/generator.c +index a135e28348..2cdca5685f 100644 +--- ext/json/generator/generator.c ++++ ext/json/generator/generator.c +@@ -301,7 +301,7 @@ static char *fstrndup(const char *ptr, unsigned long len) { + char *result; + if (len <= 0) return NULL; + result = ALLOC_N(char, len); +- memccpy(result, ptr, 0, len); ++ memcpy(result, ptr, len); + return result; + } + +@@ -1055,7 +1055,7 @@ static VALUE cState_indent_set(VALUE self, VALUE indent) + } + } else { + if (state->indent) ruby_xfree(state->indent); +- state->indent = strdup(RSTRING_PTR(indent)); ++ state->indent = fstrndup(RSTRING_PTR(indent), len); + state->indent_len = len; + } + return Qnil; +@@ -1093,7 +1093,7 @@ static VALUE cState_space_set(VALUE self, VALUE space) + } + } else { + if (state->space) ruby_xfree(state->space); +- state->space = strdup(RSTRING_PTR(space)); ++ state->space = fstrndup(RSTRING_PTR(space), len); + state->space_len = len; + } + return Qnil; +@@ -1129,7 +1129,7 @@ static VALUE cState_space_before_set(VALUE self, VALUE space_before) + } + } else { + if (state->space_before) ruby_xfree(state->space_before); +- state->space_before = strdup(RSTRING_PTR(space_before)); ++ state->space_before = fstrndup(RSTRING_PTR(space_before), len); + state->space_before_len = len; + } + return Qnil; +@@ -1166,7 +1166,7 @@ static VALUE cState_object_nl_set(VALUE self, VALUE object_nl) + } + } else { + if (state->object_nl) ruby_xfree(state->object_nl); +- state->object_nl = strdup(RSTRING_PTR(object_nl)); ++ state->object_nl = fstrndup(RSTRING_PTR(object_nl), len); + state->object_nl_len = len; + } + return Qnil; +@@ -1201,7 +1201,7 @@ static VALUE cState_array_nl_set(VALUE self, VALUE array_nl) + } + } else { + if (state->array_nl) ruby_xfree(state->array_nl); +- state->array_nl = strdup(RSTRING_PTR(array_nl)); ++ state->array_nl = fstrndup(RSTRING_PTR(array_nl), len); + state->array_nl_len = len; + } + return Qnil; +diff --git ext/json/generator/generator.h ext/json/generator/generator.h +index 298c0a4965..6bbf817b7d 100644 +--- ext/json/generator/generator.h ++++ ext/json/generator/generator.h +@@ -1,7 +1,6 @@ + #ifndef _GENERATOR_H_ + #define _GENERATOR_H_ + +-#include <string.h> + #include <math.h> + #include <ctype.h> + +diff --git ext/json/lib/json/version.rb ext/json/lib/json/version.rb +index b5748334b9..cd7ddf8777 100644 +--- ext/json/lib/json/version.rb ++++ ext/json/lib/json/version.rb +@@ -1,7 +1,7 @@ + # frozen_string_literal: false + module JSON + # JSON version +- VERSION = '2.0.2' ++ VERSION = '2.0.2.1' + VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: + VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: + VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: diff --git a/patchsets/patches-2.4.1-r4/005_no-undefined-ext.patch b/patchsets/patches-2.4.1-r4/005_no-undefined-ext.patch new file mode 100644 index 0000000..f279932 --- /dev/null +++ b/patchsets/patches-2.4.1-r4/005_no-undefined-ext.patch @@ -0,0 +1,11 @@ +--- ruby-1.9.3-preview1.orig/configure.in ++++ ruby-1.9.3-preview1/configure.in +@@ -2038,7 +2038,7 @@ if test "$with_dln_a_out" != yes; then + [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -Wl,-export-dynamic" ++ LDFLAGS="$LDFLAGS -Wl,-export-dynamic -Wl,--no-undefined" + fi + rb_cv_dlopen=yes], + [interix*], [ : ${LDSHARED='$(CC) -shared'} diff --git a/patchsets/patches-2.4.1-r4/006_static-linked-ext.patch b/patchsets/patches-2.4.1-r4/006_static-linked-ext.patch new file mode 100644 index 0000000..7404562 --- /dev/null +++ b/patchsets/patches-2.4.1-r4/006_static-linked-ext.patch @@ -0,0 +1,26 @@ +From b3dbeb6e90f316584f70e33f6bfb9d83fa5f30d3 Mon Sep 17 00:00:00 2001 +From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Sat, 28 Jan 2017 05:02:39 +0000 +Subject: [PATCH] mkmf.rb: fix script installation + +* lib/mkmf.rb (MakeMakefile): fix condition to install script + files. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + lib/mkmf.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/mkmf.rb b/lib/mkmf.rb +index 34dbcda657e1..3b500ec782b2 100644 +--- a/lib/mkmf.rb ++++ b/lib/mkmf.rb +@@ -2306,7 +2306,7 @@ def create_makefile(target, srcprefix = nil) + mfile.puts(conf) + mfile.print " + all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"} +-static: #{$extmk && !$static ? "all" : "$(STATIC_LIB)#{!$extmk ? " install-rb" : ""}"} ++static: #{$extmk && !$static ? "all" : "$(STATIC_LIB)#{$extout ? " install-rb" : ""}"} + .PHONY: all install static install-so install-rb + .PHONY: clean clean-so clean-static clean-rb + " #" diff --git a/patchsets/patches-2.4.1-r4/009_no-gems.patch b/patchsets/patches-2.4.1-r4/009_no-gems.patch new file mode 100644 index 0000000..cdf503c --- /dev/null +++ b/patchsets/patches-2.4.1-r4/009_no-gems.patch @@ -0,0 +1,112 @@ +--- tool/rbinstall.rb.~1~ 2016-10-17 09:17:07.000000000 +0200 ++++ tool/rbinstall.rb 2016-12-25 08:20:07.873491045 +0100 +@@ -695,107 +695,11 @@ + # :startdoc: + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "default gems", gem_dir, directories +- +- spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0]) +- default_spec_dir = "#{spec_dir}/default" +- makedirs(default_spec_dir) +- +- gems = Dir.glob(srcdir+"/{lib,ext}/**/*.gemspec").map {|src| +- spec = Gem::Specification.load(src) || raise("invalid spec in #{src}") +- file_collector = RbInstall::Specs::FileCollector.new(File.dirname(src)) +- files = file_collector.collect +- next if files.empty? +- spec.files = files +- spec +- } +- gems.compact.sort_by(&:name).each do |gemspec| +- full_name = "#{gemspec.name}-#{gemspec.version}" +- +- puts "#{" "*30}#{gemspec.name} #{gemspec.version}" +- gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec") +- open_for_install(gemspec_path, $data_mode) do +- gemspec.to_ruby +- end +- +- unless gemspec.executables.empty? then +- bin_dir = File.join(gem_dir, 'gems', full_name, gemspec.bindir) +- makedirs(bin_dir) +- +- execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)} +- install(execs, bin_dir, :mode => $script_mode) +- end +- end ++ # gems are unbundled in Gentoo + end + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "bundle gems", gem_dir, directories +- install_dir = with_destdir(gem_dir) +- installed_gems = {} +- options = { +- :install_dir => install_dir, +- :bin_dir => with_destdir(bindir), +- :domain => :local, +- :ignore_dependencies => true, +- :dir_mode => $dir_mode, +- :data_mode => $data_mode, +- :prog_mode => $prog_mode, +- :wrappers => true, +- :format_executable => true, +- } +- gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}" +- extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir +- Gem::Specification.each_gemspec([srcdir+'/gems/*']) do |path| +- dir = File.dirname(path) +- spec = Dir.chdir(dir) { +- Gem::Specification.load(File.basename(path)) +- } +- next unless spec.platform == Gem::Platform::RUBY +- next unless spec.full_name == path[srcdir.size..-1][/\A\/gems\/([^\/]+)/, 1] +- spec.extension_dir = "#{extensions_dir}/#{spec.full_name}" +- if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}") +- spec.extensions[0] ||= "-" +- end +- ins = RbInstall::UnpackedInstaller.new(spec, options) +- puts "#{" "*30}#{spec.name} #{spec.version}" +- ins.install +- File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec")) +- unless spec.extensions.empty? +- install_recursive(ext, spec.extension_dir) +- end +- installed_gems[spec.full_name] = true +- end +- installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))} +- unless installed_gems.empty? +- install installed_gems, gem_dir+"/cache" +- end +- next if gems.empty? +- if defined?(Zlib) +- Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name))) +- silent = Gem::SilentUI.new +- gems.each do |gem| +- inst = Gem::Installer.new(gem, options) +- inst.spec.extension_dir = with_destdir(inst.spec.extension_dir) +- begin +- Gem::DefaultUserInteraction.use_ui(silent) {inst.install} +- rescue Gem::InstallError => e +- next +- end +- gemname = File.basename(gem) +- puts "#{" "*30}#{gemname}" +- end +- # fix directory permissions +- # TODO: Gem.install should accept :dir_mode option or something +- File.chmod($dir_mode, *Dir.glob(install_dir+"/**/")) +- # fix .gemspec permissions +- File.chmod($data_mode, *Dir.glob(install_dir+"/specifications/*.gemspec")) +- else +- puts "skip installing bundle gems because of lacking zlib" +- end ++ # gems are unbundled in Gentoo + end + + parse_args() diff --git a/patchsets/patches-2.4.2/001_jemalloc-libgmp.patch b/patchsets/patches-2.4.2/001_jemalloc-libgmp.patch new file mode 100644 index 0000000..fddd810 --- /dev/null +++ b/patchsets/patches-2.4.2/001_jemalloc-libgmp.patch @@ -0,0 +1,40 @@ +diff -pU3 a/configure b/configure +--- a/configure 2017-09-14 21:52:19.000000000 +0900 ++++ b/configure 2017-09-15 07:03:12.000000000 +0900 +@@ -10614,6 +10614,7 @@ fi + ac_res=$ac_cv_search___gmpz_init + if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ++ $as_echo "#define HAVE_LIBGMP 1" >>confdefs.h + + fi + +@@ -10683,6 +10684,7 @@ fi + ac_res=$ac_cv_search_malloc_conf + if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ++ $as_echo "#define HAVE_LIBJEMALLOC 1" >>confdefs.h + + else + with_jemalloc=no +diff -pU3 a/configure.in b/configure.in +--- a/configure.in 2017-08-04 23:39:29.000000000 +0900 ++++ b/configure.in 2017-09-15 07:20:40.000000000 +0900 +@@ -1403,13 +1403,15 @@ AC_ARG_WITH([gmp], + AS_IF([test "x$with_gmp" != xno], + [AC_CHECK_HEADERS(gmp.h) + AS_IF([test "x$ac_cv_header_gmp_h" != xno], +- AC_SEARCH_LIBS([__gmpz_init], [gmp]))]) ++ AC_SEARCH_LIBS([__gmpz_init], [gmp], ++ [AC_DEFINE(HAVE_LIBGMP, 1)]))]) + + AC_ARG_WITH([jemalloc], + [AS_HELP_STRING([--with-jemalloc],[use jemalloc allocator])], + [with_jemalloc=$withval], [with_jemalloc=no]) + AS_IF([test "x$with_jemalloc" = xyes],[ +- AC_SEARCH_LIBS([malloc_conf], [jemalloc], [], [with_jemalloc=no]) ++ AC_SEARCH_LIBS([malloc_conf], [jemalloc], ++ [AC_DEFINE(HAVE_LIBJEMALLOC, 1)], [with_jemalloc=no]) + AC_CHECK_HEADER(jemalloc/jemalloc.h, [ + AC_DEFINE(RUBY_ALTERNATIVE_MALLOC_HEADER, [<jemalloc/jemalloc.h>]) + ]) diff --git a/patchsets/patches-2.4.2/002_windows_crossdev.patch b/patchsets/patches-2.4.2/002_windows_crossdev.patch new file mode 100644 index 0000000..7e290d4 --- /dev/null +++ b/patchsets/patches-2.4.2/002_windows_crossdev.patch @@ -0,0 +1,64 @@ +Bug: https://bugs.gentoo.org/show_bug.cgi?id=618878 + +A few patches to make crossdev for mingw-w64 play nice with ruby's ebuilds. +Basic gist is that without the following patch to configure.in ruby-2.4.1 +hardcodes 240 into the shared, static, and import library names, which when +built with the current ruby ebuilds results in names like libx64-msvcrt-ruby24240.dll and so on. The patch is in ruby-trunk[1], but may take a while +to hit the tarballs that gentoo uses. + +Index: configure.in +=================================================================== +--- a/configure.in (revision 57824) ++++ b/configure.in (revision 57825) +@@ -3825,7 +3825,23 @@ + + AC_ARG_WITH(soname, + AS_HELP_STRING([--with-soname=SONAME], [base name of shared library]), +- [RUBY_SO_NAME=$withval], [RUBY_SO_NAME='$(RUBY_BASE_NAME)']) ++ [RUBY_SO_NAME=$withval], ++ [ ++ AS_CASE(["$target_os"], ++ [darwin*], [ ++ RUBY_SO_NAME='$(RUBY_BASE_NAME).$(RUBY_PROGRAM_VERSION)' ++ ], ++ [cygwin*], [ ++ RUBY_SO_NAME='$(RUBY_BASE_NAME)$(MAJOR)$(MINOR)0' ++ ], ++ [mingw*], [ ++ RUBY_SO_NAME="${rb_cv_msvcrt}"'-$(RUBY_BASE_NAME)$(MAJOR)$(MINOR)0' ++ AS_IF([test x"${target_cpu}" != xi386], [ ++ RUBY_SO_NAME="${target_cpu}-${RUBY_SO_NAME}" ++ ]) ++ ], ++ [RUBY_SO_NAME='$(RUBY_BASE_NAME)']) ++ ]) + + LIBRUBY_LDSHARED=$LDSHARED + LIBRUBY_DLDFLAGS=$DLDFLAGS +@@ -3925,7 +3941,6 @@ + SOLIBS='-lm -lc' + ], + [darwin*], [ +- RUBY_SO_NAME="$RUBY_SO_NAME"'.$(RUBY_PROGRAM_VERSION)' + LIBRUBY_LDSHARED='$(CC) -dynamiclib' + if test "$load_relative" = yes; then + libprefix="@executable_path/../${libdir_basename}" +@@ -4157,7 +4172,6 @@ + fi + ], + [cygwin*|mingw*], [ +- RUBY_SO_NAME="${RUBY_SO_NAME}"'$(MAJOR)$(MINOR)0' + LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)' + AS_CASE(["$target_os"], + [cygwin*], [ +@@ -4167,10 +4181,6 @@ + fi + ], + [mingw*], [ +- RUBY_SO_NAME="${rb_cv_msvcrt}-${RUBY_SO_NAME}" +- if test x"${target_cpu}" != xi386; then +- RUBY_SO_NAME="${target_cpu}-${RUBY_SO_NAME}" +- fi + if test x"$enable_shared" = xyes; then + LIBRUBY_SO='$(RUBY_SO_NAME)'.dll + LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' $(RUBYDEF)' diff --git a/patchsets/patches-2.4.2/005_no-undefined-ext.patch b/patchsets/patches-2.4.2/005_no-undefined-ext.patch new file mode 100644 index 0000000..f279932 --- /dev/null +++ b/patchsets/patches-2.4.2/005_no-undefined-ext.patch @@ -0,0 +1,11 @@ +--- ruby-1.9.3-preview1.orig/configure.in ++++ ruby-1.9.3-preview1/configure.in +@@ -2038,7 +2038,7 @@ if test "$with_dln_a_out" != yes; then + [linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi* | kopensolaris*-gnu], [ + : ${LDSHARED='$(CC) -shared'} + if test "$rb_cv_binary_elf" = yes; then +- LDFLAGS="$LDFLAGS -Wl,-export-dynamic" ++ LDFLAGS="$LDFLAGS -Wl,-export-dynamic -Wl,--no-undefined" + fi + rb_cv_dlopen=yes], + [interix*], [ : ${LDSHARED='$(CC) -shared'} diff --git a/patchsets/patches-2.4.2/009_no-gems.patch b/patchsets/patches-2.4.2/009_no-gems.patch new file mode 100644 index 0000000..cdf503c --- /dev/null +++ b/patchsets/patches-2.4.2/009_no-gems.patch @@ -0,0 +1,112 @@ +--- tool/rbinstall.rb.~1~ 2016-10-17 09:17:07.000000000 +0200 ++++ tool/rbinstall.rb 2016-12-25 08:20:07.873491045 +0100 +@@ -695,107 +695,11 @@ + # :startdoc: + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "default gems", gem_dir, directories +- +- spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0]) +- default_spec_dir = "#{spec_dir}/default" +- makedirs(default_spec_dir) +- +- gems = Dir.glob(srcdir+"/{lib,ext}/**/*.gemspec").map {|src| +- spec = Gem::Specification.load(src) || raise("invalid spec in #{src}") +- file_collector = RbInstall::Specs::FileCollector.new(File.dirname(src)) +- files = file_collector.collect +- next if files.empty? +- spec.files = files +- spec +- } +- gems.compact.sort_by(&:name).each do |gemspec| +- full_name = "#{gemspec.name}-#{gemspec.version}" +- +- puts "#{" "*30}#{gemspec.name} #{gemspec.version}" +- gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec") +- open_for_install(gemspec_path, $data_mode) do +- gemspec.to_ruby +- end +- +- unless gemspec.executables.empty? then +- bin_dir = File.join(gem_dir, 'gems', full_name, gemspec.bindir) +- makedirs(bin_dir) +- +- execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)} +- install(execs, bin_dir, :mode => $script_mode) +- end +- end ++ # gems are unbundled in Gentoo + end + + install?(:ext, :comm, :gem) do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "bundle gems", gem_dir, directories +- install_dir = with_destdir(gem_dir) +- installed_gems = {} +- options = { +- :install_dir => install_dir, +- :bin_dir => with_destdir(bindir), +- :domain => :local, +- :ignore_dependencies => true, +- :dir_mode => $dir_mode, +- :data_mode => $data_mode, +- :prog_mode => $prog_mode, +- :wrappers => true, +- :format_executable => true, +- } +- gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}" +- extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir +- Gem::Specification.each_gemspec([srcdir+'/gems/*']) do |path| +- dir = File.dirname(path) +- spec = Dir.chdir(dir) { +- Gem::Specification.load(File.basename(path)) +- } +- next unless spec.platform == Gem::Platform::RUBY +- next unless spec.full_name == path[srcdir.size..-1][/\A\/gems\/([^\/]+)/, 1] +- spec.extension_dir = "#{extensions_dir}/#{spec.full_name}" +- if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}") +- spec.extensions[0] ||= "-" +- end +- ins = RbInstall::UnpackedInstaller.new(spec, options) +- puts "#{" "*30}#{spec.name} #{spec.version}" +- ins.install +- File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec")) +- unless spec.extensions.empty? +- install_recursive(ext, spec.extension_dir) +- end +- installed_gems[spec.full_name] = true +- end +- installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))} +- unless installed_gems.empty? +- install installed_gems, gem_dir+"/cache" +- end +- next if gems.empty? +- if defined?(Zlib) +- Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name))) +- silent = Gem::SilentUI.new +- gems.each do |gem| +- inst = Gem::Installer.new(gem, options) +- inst.spec.extension_dir = with_destdir(inst.spec.extension_dir) +- begin +- Gem::DefaultUserInteraction.use_ui(silent) {inst.install} +- rescue Gem::InstallError => e +- next +- end +- gemname = File.basename(gem) +- puts "#{" "*30}#{gemname}" +- end +- # fix directory permissions +- # TODO: Gem.install should accept :dir_mode option or something +- File.chmod($dir_mode, *Dir.glob(install_dir+"/**/")) +- # fix .gemspec permissions +- File.chmod($data_mode, *Dir.glob(install_dir+"/specifications/*.gemspec")) +- else +- puts "skip installing bundle gems because of lacking zlib" +- end ++ # gems are unbundled in Gentoo + end + + parse_args() |