From 1e7260221818aaaff726e7141f211251c54db14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Sat, 16 Jan 2021 11:43:47 +0100 Subject: [PATCH] Fix SEGFAULT in rubygem-shoulda-matchers test suite. --- ...ry-to-clear-cache-on-garbage-objects.patch | 31 +++++++++++++++++++ ruby.spec | 10 +++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 ruby-3.0.0-Dont-try-to-clear-cache-on-garbage-objects.patch diff --git a/ruby-3.0.0-Dont-try-to-clear-cache-on-garbage-objects.patch b/ruby-3.0.0-Dont-try-to-clear-cache-on-garbage-objects.patch new file mode 100644 index 0000000..f97b2d0 --- /dev/null +++ b/ruby-3.0.0-Dont-try-to-clear-cache-on-garbage-objects.patch @@ -0,0 +1,31 @@ +From 0b54279d63c4be355e0ce9cc0b81e3df75045791 Mon Sep 17 00:00:00 2001 +From: Aaron Patterson +Date: Fri, 15 Jan 2021 14:14:43 -0800 +Subject: [PATCH] Don't try to clear cache on garbage objects + +Method cache can be cleared during lazy sweeping. An object that will +be collected during lazy sweep *should not* have it's method cache +cleared. Soon-to-be-collected objects can be in an inconsistent state and +this can lead to a crash. This patch just leaves early if the object is +going to be collected. + +Fixes [Bug #17536] + +Co-Authored-By: John Hawthorn +Co-Authored-By: Alan Wu +--- + vm_method.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/vm_method.c b/vm_method.c +index 287d4aee6dea..81920bbe5bfb 100644 +--- a/vm_method.c ++++ b/vm_method.c +@@ -136,6 +136,7 @@ static void + clear_method_cache_by_id_in_class(VALUE klass, ID mid) + { + VM_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_ICLASS)); ++ if (rb_objspace_garbage_object_p(klass)) return; + + if (LIKELY(RCLASS_EXT(klass)->subclasses == NULL)) { + // no subclasses diff --git a/ruby.spec b/ruby.spec index 49aecaa..e10ef27 100644 --- a/ruby.spec +++ b/ruby.spec @@ -22,7 +22,7 @@ %endif -%global release 143 +%global release 144 %{!?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 @@ -149,6 +149,10 @@ Patch9: ruby-2.3.1-Rely-on-ldd-to-detect-glibc.patch # Fix SEGFAULT preventing rubygem-unicode to build on armv7hl. # https://bugs.ruby-lang.org/issues/17518 Patch10: ruby-3.0.0-Fixed-dangling-imemo_tmpbuf.patch +# Fix SEGFAULT in rubygem-shoulda-matchers test suite. +# https://bugs.ruby-lang.org/issues/17536 +# https://github.com/ruby/ruby/pull/4077 +Patch11: ruby-3.0.0-Dont-try-to-clear-cache-on-garbage-objects.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 @@ -609,6 +613,7 @@ rm -rf ext/fiddle/libffi* %patch6 -p1 %patch9 -p1 %patch10 -p1 +%patch11 -p1 %patch19 -p1 # Provide an example of usage of the tapset: @@ -1390,6 +1395,9 @@ MSPECOPTS="$MSPECOPTS -P 'raises TypeError if one of the passed exceptions is no %changelog +* Sat Jan 16 2021 Vít Ondruch - 3.0.0-144 +- Fix SEGFAULT in rubygem-shoulda-matchers test suite. + * Tue Jan 12 2021 Vít Ondruch - 3.0.0-143 - Provide `gem.build_complete` file for binary gems.