[前][次][番号順一覧][スレッド一覧]

ruby-changes:50385

From: naruse <ko1@a...>
Date: Wed, 21 Feb 2018 05:11:53 +0900 (JST)
Subject: [ruby-changes:50385] naruse:r62501 (ruby_2_5): merge revision(s) 62116, 62151: [Backport #14425]

naruse	2018-02-21 05:11:47 +0900 (Wed, 21 Feb 2018)

  New Revision: 62501

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62501

  Log:
    merge revision(s) 62116,62151: [Backport #14425]
    
    ruby.h: relax rb_funcall check on extra args for clang
    
    clang 5.+ (tested clang 7.0.0) seems to be attempting division-by-zero
    and giving a very large number for static args to rb_funcall.
    
    * include/ruby/ruby.h (rb_varargs_bad_length): relax check for clang
    * ext/-test-/funcall/funcall.c: renamed from passing_block.c
      define extra_args_name function
    * test/-ext-/funcall/test_funcall.rb: new test
      [ruby-core:85266] [Bug #14425]
    
    From: Eric Wong <e@8...>
    
    ruby.h: relax rb_funcall(obj, id, 0, 0) case only
    
    * include/ruby/ruby.h (rb_varargs_argc_valid_p): relax rb_funcall
      check on extra args only if argc == 0, for the compatibility
      with wrong code which is probably confused with rb_funcallv.
      [Bug #14425]

  Added files:
    branches/ruby_2_5/ext/-test-/funcall/funcall.c
    branches/ruby_2_5/test/-ext-/funcall/test_funcall.rb
  Removed files:
    branches/ruby_2_5/ext/-test-/funcall/passing_block.c
  Modified directories:
    branches/ruby_2_5/
  Modified files:
    branches/ruby_2_5/include/ruby/ruby.h
    branches/ruby_2_5/version.h
Index: ruby_2_5/ext/-test-/funcall/passing_block.c
===================================================================
--- ruby_2_5/ext/-test-/funcall/passing_block.c	(revision 62500)
+++ ruby_2_5/ext/-test-/funcall/passing_block.c	(nonexistent)
@@ -1,30 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/ext/-test-/funcall/passing_block.c#L0
-#include "ruby.h"
-
-VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
-
-static VALUE
-with_funcall2(int argc, VALUE *argv, VALUE self)
-{
-    return rb_funcallv(self, rb_intern("target"), argc, argv);
-}
-
-static VALUE
-with_funcall_passing_block(int argc, VALUE *argv, VALUE self)
-{
-    return rb_funcall_passing_block(self, rb_intern("target"), argc, argv);
-}
-
-void
-Init_funcall(void)
-{
-    VALUE cRelay = rb_path2class("TestFuncall::Relay");
-
-    rb_define_singleton_method(cRelay,
-			       "with_funcall2",
-			       with_funcall2,
-			       -1);
-    rb_define_singleton_method(cRelay,
-			       "with_funcall_passing_block",
-			       with_funcall_passing_block,
-			       -1);
-}

Property changes on: ruby_2_5/ext/-test-/funcall/passing_block.c
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Index: ruby_2_5/version.h
===================================================================
--- ruby_2_5/version.h	(revision 62500)
+++ ruby_2_5/version.h	(revision 62501)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1
 #define RUBY_VERSION "2.5.0"
-#define RUBY_RELEASE_DATE "2018-02-19"
-#define RUBY_PATCHLEVEL 24
+#define RUBY_RELEASE_DATE "2018-02-21"
+#define RUBY_PATCHLEVEL 25
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 19
+#define RUBY_RELEASE_DAY 21
 
 #include "ruby/version.h"
 
Index: ruby_2_5/include/ruby/ruby.h
===================================================================
--- ruby_2_5/include/ruby/ruby.h	(revision 62500)
+++ ruby_2_5/include/ruby/ruby.h	(revision 62501)
@@ -1763,15 +1763,19 @@ VALUE rb_check_symbol(volatile VALUE *na https://github.com/ruby/ruby/blob/trunk/ruby_2_5/include/ruby/ruby.h#L1763
     (((argc) <= (vargc)) ? (argc) : \
      (rb_fatal("argc(%d) exceeds actual arguments(%d)", \
 	       argc, vargc), 0))
+# define rb_varargs_argc_valid_p(argc, vargc) \
+    ((argc) == 0 ? (vargc) <= 1 : /* [ruby-core:85266] [Bug #14425] */ \
+     (argc) == (vargc))
 # if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
 #   if HAVE_ATTRIBUTE_ERRORFUNC
 ERRORFUNC((" argument length doesn't match"), int rb_varargs_bad_length(int,int));
 #   else
-#     define rb_varargs_bad_length(argc, vargc) ((argc)/((argc) == (vargc)))
+#     define rb_varargs_bad_length(argc, vargc) \
+	((argc)/rb_varargs_argc_valid_p(argc, vargc))
 #   endif
 #   define rb_varargs_argc_check(argc, vargc) \
     __builtin_choose_expr(__builtin_constant_p(argc), \
-	(((argc) == (vargc)) ? (argc) : \
+	(rb_varargs_argc_valid_p(argc, vargc) ? (argc) : \
 	 rb_varargs_bad_length(argc, vargc)), \
 	rb_varargs_argc_check_runtime(argc, vargc))
 # else
Index: ruby_2_5/test/-ext-/funcall/test_funcall.rb
===================================================================
--- ruby_2_5/test/-ext-/funcall/test_funcall.rb	(nonexistent)
+++ ruby_2_5/test/-ext-/funcall/test_funcall.rb	(revision 62501)
@@ -0,0 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/-ext-/funcall/test_funcall.rb#L1
+# frozen_string_literal: true
+require 'test/unit'
+
+class TestFuncall < Test::Unit::TestCase
+  require '-test-/funcall'
+
+  def test_funcall_extra_args
+    assert_equal 'TestFuncall', TestFuncall.extra_args_name,
+	 '[ruby-core:85266] [Bug #14425]'
+  end
+end
Index: ruby_2_5/ext/-test-/funcall/funcall.c
===================================================================
--- ruby_2_5/ext/-test-/funcall/funcall.c	(nonexistent)
+++ ruby_2_5/ext/-test-/funcall/funcall.c	(revision 62501)
@@ -0,0 +1,44 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/ext/-test-/funcall/funcall.c#L1
+#include "ruby.h"
+
+VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
+
+static VALUE
+with_funcall2(int argc, VALUE *argv, VALUE self)
+{
+    return rb_funcallv(self, rb_intern("target"), argc, argv);
+}
+
+static VALUE
+with_funcall_passing_block(int argc, VALUE *argv, VALUE self)
+{
+    return rb_funcall_passing_block(self, rb_intern("target"), argc, argv);
+}
+
+static VALUE
+extra_args_name(VALUE self)
+{
+    /*
+     * at least clang 5.x gets tripped by the extra 0 arg
+     * [ruby-core:85266] [Bug #14425]
+     */
+    return rb_funcall(self, rb_intern("name"), 0, 0);
+}
+
+void
+Init_funcall(void)
+{
+    VALUE cTestFuncall = rb_path2class("TestFuncall");
+    VALUE cRelay = rb_define_module_under(cTestFuncall, "Relay");
+
+    rb_define_singleton_method(cRelay,
+			       "with_funcall2",
+			       with_funcall2,
+			       -1);
+    rb_define_singleton_method(cRelay,
+			       "with_funcall_passing_block",
+			       with_funcall_passing_block,
+			       -1);
+    rb_define_singleton_method(cTestFuncall, "extra_args_name",
+                                extra_args_name,
+                                0);
+}

Property changes on: ruby_2_5/ext/-test-/funcall/funcall.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ruby_2_5
===================================================================
--- ruby_2_5	(revision 62500)
+++ ruby_2_5	(revision 62501)

Property changes on: ruby_2_5
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r62116,62151

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]