Fix segfaults during generating of documentation.

This caused issued during build of rubygem-{webmock,ffi} and was fixed
as part of https://bugs.ruby-lang.org/issues/14261.
This commit is contained in:
Vít Ondruch 2018-01-09 12:49:58 +01:00
parent 9436f5bc42
commit b1741da5b7
2 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,80 @@
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Sun, 31 Dec 2017 11:25:38 +0000
Subject: [PATCH] parse.y: assignable_error
* parse.y (assignable_gen): should return valid NODE always even
on errors. [ruby-core:84565] [Bug #14261]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
parse.c | 14 ++++----------
test/ruby/test_parse.rb | 6 ++++++
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/parse.c b/parse.c
index 08c3461f7096..c260a046dc33 100644
--- a/parse.c
+++ b/parse.c
@@ -6593,10 +6593,6 @@
#line 1984 "parse.y" /* yacc.c:1646 */
{
(yyval.node) = assignable(var_field((yyvsp[0].id)), 0, &(yyloc));
- /*%%%*/
- if (!(yyval.node)) (yyval.node) = new_begin(0, &(yyloc));
- /*%
- %*/
}
#line 6598 "parse.c" /* yacc.c:1646 */
break;
@@ -6605,10 +6601,6 @@
#line 1992 "parse.y" /* yacc.c:1646 */
{
(yyval.node) = assignable(var_field((yyvsp[0].id)), 0, &(yyloc));
- /*%%%*/
- if (!(yyval.node)) (yyval.node) = new_begin(0, &(yyloc));
- /*%
- %*/
}
#line 6610 "parse.c" /* yacc.c:1646 */
break;
@@ -16034,11 +16026,13 @@
#ifdef RIPPER
ID id = get_id(lhs);
# define assignable_result(x) (lhs)
+# define assignable_error() (lhs)
# define parser_yyerror(parser, x) (lhs = assign_error_gen(parser, lhs))
#else
# define assignable_result(x) assignable_result0(x, location)
+# define assignable_error() new_begin(0, location)
#endif
- if (!id) return assignable_result(0);
+ if (!id) return assignable_error();
switch (id) {
case keyword_self:
yyerror0("Can't change the value of self");
@@ -16101,7 +16095,7 @@
compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id));
}
error:
- return assignable_result(0);
+ return assignable_error();
#undef assignable_result
#undef parser_yyerror
}
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index e26bcdc07e19..15c6245bac2e 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -746,6 +746,12 @@ def foo
end
END
end
+ assert_raise(SyntaxError) do
+ eval "#{<<~"begin;"}\n#{<<~'end;'}", nil, __FILE__, __LINE__+1
+ begin;
+ x, true
+ end;
+ end
end
def test_block_dup

View File

@ -21,7 +21,7 @@
%endif
%global release 86
%global release 87
%{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}}
# The RubyGems library has to stay out of Ruby directory three, since the
@ -134,6 +134,9 @@ Patch9: ruby-2.3.1-Rely-on-ldd-to-detect-glibc.patch
# Add Gem.operating_system_defaults to allow packagers to override defaults.
# https://github.com/rubygems/rubygems/pull/2116
Patch10: ruby-2.5.0-Add-Gem.operating_system_defaults.patch
# Fix segfault during generating documentation.
# https://bugs.ruby-lang.org/issues/14343
Patch11: ruby-2.5.0-parse.y-assignable_error.patch
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Suggests: rubypick
@ -516,6 +519,7 @@ rm -rf ext/fiddle/libffi*
%patch7 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
# Provide an example of usage of the tapset:
cp -a %{SOURCE3} .
@ -1058,6 +1062,9 @@ make check TESTS="-v $DISABLE_TESTS"
%{gem_dir}/specifications/xmlrpc-%{xmlrpc_version}.gemspec
%changelog
* Tue Jan 09 2018 Vít Ondruch <vondruch@redhat.com> - 2.5.0-87
- Fix segfaults during generating of documentation.
* Tue Jan 02 2018 Vít Ondruch <vondruch@redhat.com> - 2.5.0-1
- Upgrade to Ruby 2.5.0.