summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_optimization.rb15
-rw-r--r--version.h2
-rw-r--r--vm_args.c3
4 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index bd1b860c53..ff2a80b2ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Jul 30 12:23:29 2016 Shugo Maeda <shugo@ruby-lang.org>
+
+ * vm_args.c (vm_caller_setup_arg_block): disable symbol block
+ argument optimization when tail call optimization is enabled,
+ in order to avoid SEGV. [ruby-core:76288] [Bug #12565]
+
Sat Jul 30 12:10:51 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* proc.c (passed_block): convert passed block symbol to proc.
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index 15fb9195c9..f147f9d8c6 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -319,6 +319,21 @@ class TestRubyOptimization < Test::Unit::TestCase
assert_equal("should be rescued", result.message, bug12082)
end
+ def test_tailcall_symbol_block_arg
+ bug12565 = '[ruby-core:46065]'
+ tailcall(<<-EOF)
+ def apply_one_and_two(&block)
+ yield(1, 2)
+ end
+
+ def add_one_and_two
+ apply_one_and_two(&:+)
+ end
+ EOF
+ assert_equal(3, add_one_and_two,
+ message(bug12565) {disasm(:add_one_and_two)})
+ end
+
class Bug10557
def [](_)
block_given?
diff --git a/version.h b/version.h
index e8531585af..7342fe910a 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.2"
#define RUBY_RELEASE_DATE "2016-07-30"
-#define RUBY_PATCHLEVEL 141
+#define RUBY_PATCHLEVEL 142
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 7
diff --git a/vm_args.c b/vm_args.c
index 2546b86e8e..037fb09c1f 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -780,7 +780,8 @@ vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp,
if (NIL_P(proc)) {
calling->blockptr = NULL;
}
- else if (SYMBOL_P(proc) && rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) {
+ else if (LIKELY(!(ci->flag & VM_CALL_TAILCALL)) && SYMBOL_P(proc) &&
+ rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) {
calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
calling->blockptr->iseq = (rb_iseq_t *)proc;
calling->blockptr->proc = proc;