Avoid ruby-spec to be stuck in "C-API Kernel function rb_rescue2".

This commit is contained in:
Vít Ondruch 2021-02-16 10:00:33 +01:00
parent 35f28c9a68
commit 3210f66fb1
2 changed files with 69 additions and 4 deletions

View File

@ -0,0 +1,65 @@
From 85310ad82ede533681c4f8a423cc8f140e6adf76 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
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 <nobu@ruby-lang.org>
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;

View File

@ -156,6 +156,9 @@ Patch11: ruby-3.0.0-Dont-try-to-clear-cache-on-garbage-objects.patch
# Use proper path for plugin wrappers. # Use proper path for plugin wrappers.
# https://github.com/rubygems/rubygems/pull/4317 # https://github.com/rubygems/rubygems/pull/4317
Patch12: rubygems-3.2.7-Generate-plugin-wrappers-with-relative-requires.patch 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
# 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
@ -607,6 +610,7 @@ rm -rf ext/fiddle/libffi*
%patch10 -p1 %patch10 -p1
%patch11 -p1 %patch11 -p1
%patch12 -p1 %patch12 -p1
%patch13 -p1
%patch19 -p1 %patch19 -p1
# Provide an example of usage of the tapset: # Provide an example of usage of the tapset:
@ -891,10 +895,6 @@ DISABLE_TESTS="$DISABLE_TESTS -n !/test_bug_reporter_add/"
# Avoid `hostname' dependency. # Avoid `hostname' dependency.
%{!?with_hostname:MSPECOPTS="-P 'Socket.gethostname returns the host name'"} %{!?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. # Give an option to increase the timeout in tests.
# https://bugs.ruby-lang.org/issues/16921 # https://bugs.ruby-lang.org/issues/16921
%{?test_timeout_scale:RUBY_TEST_TIMEOUT_SCALE="%{test_timeout_scale}"} \ %{?test_timeout_scale:RUBY_TEST_TIMEOUT_SCALE="%{test_timeout_scale}"} \