Fix SEGFAULT in rubygem-shoulda-matchers test suite.

This commit is contained in:
Vít Ondruch 2021-01-16 11:43:47 +01:00
parent 0256efd992
commit 1e72602218
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,31 @@
From 0b54279d63c4be355e0ce9cc0b81e3df75045791 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@ruby-lang.org>
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 <john@hawthorn.email>
Co-Authored-By: Alan Wu <XrXr@users.noreply.github.com>
---
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

View File

@ -22,7 +22,7 @@
%endif %endif
%global release 143 %global release 144
%{!?release_string:%define release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} %{!?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 # 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. # Fix SEGFAULT preventing rubygem-unicode to build on armv7hl.
# https://bugs.ruby-lang.org/issues/17518 # https://bugs.ruby-lang.org/issues/17518
Patch10: ruby-3.0.0-Fixed-dangling-imemo_tmpbuf.patch 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. # Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add.
# https://bugs.ruby-lang.org/issues/16492 # https://bugs.ruby-lang.org/issues/16492
Patch19: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch 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 %patch6 -p1
%patch9 -p1 %patch9 -p1
%patch10 -p1 %patch10 -p1
%patch11 -p1
%patch19 -p1 %patch19 -p1
# Provide an example of usage of the tapset: # 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 %changelog
* Sat Jan 16 2021 Vít Ondruch <vondruch@redhat.com> - 3.0.0-144
- Fix SEGFAULT in rubygem-shoulda-matchers test suite.
* Tue Jan 12 2021 Vít Ondruch <vondruch@redhat.com> - 3.0.0-143 * Tue Jan 12 2021 Vít Ondruch <vondruch@redhat.com> - 3.0.0-143
- Provide `gem.build_complete` file for binary gems. - Provide `gem.build_complete` file for binary gems.