From 3210f66fb138765903d77d679ee2beadb0eba3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 16 Feb 2021 10:00:33 +0100 Subject: [PATCH] Avoid ruby-spec to be stuck in "C-API Kernel function rb_rescue2". --- ...a_list-args-in-rb_vrescue2-is-reused.patch | 65 +++++++++++++++++++ ruby.spec | 8 +-- 2 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 ruby-3.0.0-va_list-args-in-rb_vrescue2-is-reused.patch 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.spec b/ruby.spec index 13dd4a3..3ad310f 100644 --- a/ruby.spec +++ b/ruby.spec @@ -156,6 +156,9 @@ 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 # 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 +610,7 @@ rm -rf ext/fiddle/libffi* %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch13 -p1 %patch19 -p1 # Provide an example of usage of the tapset: @@ -891,10 +895,6 @@ DISABLE_TESTS="$DISABLE_TESTS -n !/test_bug_reporter_add/" # 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}"} \