diff --git a/ruby-3.0.0-Do-not-allocate-ractor-local-storage-in-dfree-function-during-GC.patch b/ruby-3.0.0-Do-not-allocate-ractor-local-storage-in-dfree-function-during-GC.patch new file mode 100644 index 0000000..c63c7c3 --- /dev/null +++ b/ruby-3.0.0-Do-not-allocate-ractor-local-storage-in-dfree-function-during-GC.patch @@ -0,0 +1,24 @@ +From 265c0022390e3dcd4ff692fc77d29b94e652c877 Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Tue, 9 Feb 2021 01:00:00 +0900 +Subject: [PATCH] Do not allocate ractor-local storage in dfree function during + GC + +--- + random.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/random.c b/random.c +index c11cd803f2cb..83df6d1eb537 100644 +--- a/random.c ++++ b/random.c +@@ -257,7 +257,8 @@ const rb_data_type_t rb_random_data_type = { + static void + random_mt_free(void *ptr) + { +- if (ptr != default_rand()) ++ rb_random_mt_t *rnd = rb_ractor_local_storage_ptr(default_rand_key); ++ if (ptr != rnd) + xfree(ptr); + } + diff --git a/ruby-3.0.0-va_list-args-in-rb_vrescue2-is-reused.patch b/ruby-3.0.0-va_list-args-in-rb_vrescue2-is-reused.patch new file mode 100644 index 0000000..996d528 --- /dev/null +++ b/ruby-3.0.0-va_list-args-in-rb_vrescue2-is-reused.patch @@ -0,0 +1,65 @@ +From 85310ad82ede533681c4f8a423cc8f140e6adf76 Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Tue, 9 Feb 2021 10:08:30 +0900 +Subject: [PATCH 1/2] Also `eclass` loop can raise in `rb_obj_is_kind_of` + +--- + eval.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/eval.c b/eval.c +index 56d7c2b81c93..2c9e375e2545 100644 +--- a/eval.c ++++ b/eval.c +@@ -1034,6 +1034,7 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1, + int handle = FALSE; + VALUE eclass; + ++ result = Qnil; + while ((eclass = va_arg(args, VALUE)) != 0) { + if (rb_obj_is_kind_of(ec->errinfo, eclass)) { + handle = TRUE; +@@ -1042,7 +1043,6 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1, + } + + if (handle) { +- result = Qnil; + state = 0; + if (r_proc) { + result = (*r_proc) (data2, ec->errinfo); + +From 601d38efa21dbed0084629d909752e52e3d6092d Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Tue, 9 Feb 2021 00:42:12 +0900 +Subject: [PATCH 2/2] Copy va_list of exception classes + +The list is reused when an exception raised again after retrying +in the rescue procedure. +--- + eval.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/eval.c b/eval.c +index 2c9e375e2545..55d66b550854 100644 +--- a/eval.c ++++ b/eval.c +@@ -1033,14 +1033,18 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1, + if (state == TAG_RAISE) { + int handle = FALSE; + VALUE eclass; ++ va_list ap; + + result = Qnil; +- while ((eclass = va_arg(args, VALUE)) != 0) { ++ /* reuses args when raised again after retrying in r_proc */ ++ va_copy(ap, args); ++ while ((eclass = va_arg(ap, VALUE)) != 0) { + if (rb_obj_is_kind_of(ec->errinfo, eclass)) { + handle = TRUE; + break; + } + } ++ va_end(ap); + + if (handle) { + state = 0; diff --git a/ruby-dwarf5-avoid_crash-r1.patch b/ruby-dwarf5-avoid_crash-r1.patch new file mode 100644 index 0000000..c14642b --- /dev/null +++ b/ruby-dwarf5-avoid_crash-r1.patch @@ -0,0 +1,217 @@ +--- a/addr2line.c ++++ b/addr2line.c +@@ -159,11 +159,12 @@ + struct dwarf_section debug_info; + struct dwarf_section debug_line; + struct dwarf_section debug_ranges; ++ struct dwarf_section debug_rnglists; + struct dwarf_section debug_str; + struct obj_info *next; + } obj_info_t; + +-#define DWARF_SECTION_COUNT 5 ++#define DWARF_SECTION_COUNT 6 + + static struct dwarf_section * + obj_dwarf_section_at(obj_info_t *obj, int n) +@@ -173,6 +174,7 @@ + &obj->debug_info, + &obj->debug_line, + &obj->debug_ranges, ++ &obj->debug_rnglists, + &obj->debug_str + }; + if (n < 0 || DWARF_SECTION_COUNT <= n) { +@@ -411,7 +413,7 @@ + FILL_LINE(); + break; + case DW_LNS_advance_pc: +- a = uleb128((char **)&p); ++ a = uleb128((char **)&p) * header.minimum_instruction_length; + addr += a; + break; + case DW_LNS_advance_line: { +@@ -450,7 +452,7 @@ + /* isa = (unsigned int)*/(void)uleb128((char **)&p); + break; + case 0: +- a = *(unsigned char *)p++; ++ a = uleb128((char **)&p); + op = *p++; + switch (op) { + case DW_LNE_end_sequence: +@@ -807,6 +809,18 @@ + DW_FORM_addrx4 = 0x2c + }; + ++/* Range list entry encodings */ ++enum { ++ DW_RLE_end_of_list = 0x00, ++ DW_RLE_base_addressx = 0x01, ++ DW_RLE_startx_endx = 0x02, ++ DW_RLE_startx_length = 0x03, ++ DW_RLE_offset_pair = 0x04, ++ DW_RLE_base_address = 0x05, ++ DW_RLE_start_end = 0x06, ++ DW_RLE_start_length = 0x07 ++}; ++ + enum { + VAL_none = 0, + VAL_cstr = 1, +@@ -961,6 +975,23 @@ + } + + static void ++di_skip_die_attributes(char **p) ++{ ++ for (;;) { ++ uint64_t at = uleb128(p); ++ uint64_t form = uleb128(p); ++ if (!at && !form) break; ++ switch (form) { ++ default: ++ break; ++ case DW_FORM_implicit_const: ++ sleb128(p); ++ break; ++ } ++ } ++} ++ ++static void + di_read_debug_abbrev_cu(DebugInfoReader *reader) + { + uint64_t prev = 0; +@@ -974,12 +1005,7 @@ + prev = abbrev_number; + uleb128(&p); /* tag */ + p++; /* has_children */ +- /* skip content */ +- for (;;) { +- uint64_t at = uleb128(&p); +- uint64_t form = uleb128(&p); +- if (!at && !form) break; +- } ++ di_skip_die_attributes(&p); + } + } + +@@ -1243,12 +1269,7 @@ + /* skip 255th record */ + uleb128(&p); /* tag */ + p++; /* has_children */ +- /* skip content */ +- for (;;) { +- uint64_t at = uleb128(&p); +- uint64_t form = uleb128(&p); +- if (!at && !form) break; +- } ++ di_skip_die_attributes(&p); + for (uint64_t n = uleb128(&p); abbrev_number != n; n = uleb128(&p)) { + if (n == 0) { + fprintf(stderr,"%d: Abbrev Number %"PRId64" not found\n",__LINE__, abbrev_number); +@@ -1256,12 +1277,7 @@ + } + uleb128(&p); /* tag */ + p++; /* has_children */ +- /* skip content */ +- for (;;) { +- uint64_t at = uleb128(&p); +- uint64_t form = uleb128(&p); +- if (!at && !form) break; +- } ++ di_skip_die_attributes(&p); + } + return p; + } +@@ -1389,6 +1405,21 @@ + } + } + ++static uint64_t ++read_dw_form_addr(DebugInfoReader *reader, char **ptr) ++{ ++ char *p = *ptr; ++ *ptr = p + reader->format; ++ if (reader->format == 4) { ++ return read_uint32(&p); ++ } else if (reader->format == 8) { ++ return read_uint64(&p); ++ } else { ++ fprintf(stderr,"unknown address_size:%d", reader->address_size); ++ abort(); ++ } ++} ++ + static uintptr_t + ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr) + { +@@ -1402,8 +1433,50 @@ + } + else if (ptr->ranges_set) { + /* TODO: support base address selection entry */ +- char *p = reader->obj->debug_ranges.ptr + ptr->ranges; ++ char *p; + uint64_t base = ptr->low_pc_set ? ptr->low_pc : reader->current_low_pc; ++ if (reader->obj->debug_rnglists.ptr) { ++ p = reader->obj->debug_rnglists.ptr + ptr->ranges; ++ for (;;) { ++ uint8_t rle = read_uint8(&p); ++ uintptr_t base_address = 0; ++ uintptr_t from, to; ++ if (rle == DW_RLE_end_of_list) break; ++ switch (rle) { ++ case DW_RLE_base_addressx: ++ uleb128(&p); ++ break; ++ case DW_RLE_startx_endx: ++ uleb128(&p); ++ uleb128(&p); ++ break; ++ case DW_RLE_startx_length: ++ uleb128(&p); ++ uleb128(&p); ++ break; ++ case DW_RLE_offset_pair: ++ from = base_address + uleb128(&p); ++ to = base_address + uleb128(&p); ++ if (base + from <= addr && addr < base + to) { ++ return from; ++ } ++ break; ++ case DW_RLE_base_address: ++ base_address = read_dw_form_addr(reader, &p); ++ break; ++ case DW_RLE_start_end: ++ read_dw_form_addr(reader, &p); ++ read_dw_form_addr(reader, &p); ++ break; ++ case DW_RLE_start_length: ++ read_dw_form_addr(reader, &p); ++ uleb128(&p); ++ break; ++ } ++ } ++ return false; ++ } ++ p = reader->obj->debug_ranges.ptr + ptr->ranges; + for (;;) { + uintptr_t from = read_uintptr(&p); + uintptr_t to = read_uintptr(&p); +@@ -1747,6 +1820,7 @@ + ".debug_info", + ".debug_line", + ".debug_ranges", ++ ".debug_rnglists", + ".debug_str" + }; + +@@ -2003,6 +2077,7 @@ + "__debug_info", + "__debug_line", + "__debug_ranges", ++ "__debug_rnglists", + "__debug_str" + }; + struct LP(segment_command) *scmd = (struct LP(segment_command) *)lcmd; diff --git a/ruby.spec b/ruby.spec index 13dd4a3..c43fb0a 100644 --- a/ruby.spec +++ b/ruby.spec @@ -22,7 +22,7 @@ %endif -%global release 145 +%global release 146 %{!?release_string:%define release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} # The RubyGems library has to stay out of Ruby directory tree, since the @@ -156,6 +156,16 @@ Patch11: ruby-3.0.0-Dont-try-to-clear-cache-on-garbage-objects.patch # Use proper path for plugin wrappers. # https://github.com/rubygems/rubygems/pull/4317 Patch12: rubygems-3.2.7-Generate-plugin-wrappers-with-relative-requires.patch +# Avoid ruby-spec to be stuck in "C-API Kernel function rb_rescue2". +# https://bugs.ruby-lang.org/issues/17338 +Patch13: ruby-3.0.0-va_list-args-in-rb_vrescue2-is-reused.patch +# Fix flaky excon test suite. +# https://bugs.ruby-lang.org/issues/17653 +Patch14: ruby-3.0.0-Do-not-allocate-ractor-local-storage-in-dfree-function-during-GC.patch +# Fix DWARF5 support. +# https://bugzilla.redhat.com/show_bug.cgi?id=1920533 +# https://bugs.ruby-lang.org/issues/17585 +Patch15: ruby-dwarf5-avoid_crash-r1.patch # Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add. # https://bugs.ruby-lang.org/issues/16492 Patch19: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch @@ -607,6 +617,9 @@ rm -rf ext/fiddle/libffi* %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 %patch19 -p1 # Provide an example of usage of the tapset: @@ -879,22 +892,9 @@ make runruby TESTRUN_SCRIPT="--enable-gems %{SOURCE13}" DISABLE_TESTS="" MSPECOPTS="" -%ifarch armv7hl ppc64le -# Disable test which started to fail presumably after move to DWARF5: -# https://bugzilla.redhat.com/show_bug.cgi?id=1920533 -# Unfortunately, these used to be problematic already before: -# https://bugs.ruby-lang.org/issues/13758 -DISABLE_TESTS="$DISABLE_TESTS -n !/test_segv_\(setproctitle\|test\|loaded_features\)/" -DISABLE_TESTS="$DISABLE_TESTS -n !/test_bug_reporter_add/" -%endif - # Avoid `hostname' dependency. %{!?with_hostname:MSPECOPTS="-P 'Socket.gethostname returns the host name'"} -# The test suite gets stuck in 'C-API Kernel function rb_rescue2'. -# https://bugs.ruby-lang.org/issues/17338 -MSPECOPTS="$MSPECOPTS -P 'raises TypeError if one of the passed exceptions is not a Module'" - # Give an option to increase the timeout in tests. # https://bugs.ruby-lang.org/issues/16921 %{?test_timeout_scale:RUBY_TEST_TIMEOUT_SCALE="%{test_timeout_scale}"} \ @@ -1375,6 +1375,11 @@ MSPECOPTS="$MSPECOPTS -P 'raises TypeError if one of the passed exceptions is no %changelog +* Tue Mar 02 2021 Vít Ondruch - 3.0.0-146 +- Fix flaky excon test suite. +- Properly support DWARF5 debug information. + Resolves: rhbz#1920533 + * Mon Jan 25 2021 Vít Ondruch - 3.0.0-145 - Bundle OpenSSL into StdLib. - Use proper path for plugin wrappers.