ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:94881] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
       [not found] <redmine.issue-16161.20190910002817@ruby-lang.org>
@ 2019-09-10  0:28 ` s.wanabe
  2019-09-12  9:43 ` [ruby-core:94921] " s.wanabe
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: s.wanabe @ 2019-09-10  0:28 UTC (permalink / raw)
  To: ruby-core

Issue #16161 has been reported by wanabe (_ wanabe).

----------------------------------------
Bug #16161: tailcall_optimization may be disabled after r67315
https://bugs.ruby-lang.org/issues/16161

* Author: wanabe (_ wanabe)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Before r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67314) [x86_64-linux]
405000450000
```

After r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67315) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

master:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

I think ruby should not raise SystemStackError with tailcall_optimization, should it?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:94921] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
       [not found] <redmine.issue-16161.20190910002817@ruby-lang.org>
  2019-09-10  0:28 ` [ruby-core:94881] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315 s.wanabe
@ 2019-09-12  9:43 ` s.wanabe
  2019-10-06  6:19 ` [ruby-core:95239] " s.wanabe
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: s.wanabe @ 2019-09-12  9:43 UTC (permalink / raw)
  To: ruby-core

Issue #16161 has been updated by wanabe (_ wanabe).


How about adding `vm_call_iseq_setup_tailcall_opt_start` as same as `vm_call_iseq_setup_normal_opt_start`?
(Copy-and-paste code, sorry!)

```patch
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index a83e3a952a..4abee2fadd 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1825,6 +1825,30 @@ vm_call_iseq_setup_normal_opt_start(rb_execution_context_t *ec, rb_control_frame
     return vm_call_iseq_setup_normal(ec, cfp, calling, cc->me, opt_pc, param - delta, local);
 }
 
+static VALUE
+vm_call_iseq_setup_tailcall_opt_start(rb_execution_context_t *ec, rb_control_frame_t *cfp,
+                                      struct rb_calling_info *calling,
+                                      const struct rb_call_info *ci, struct rb_call_cache *cc)
+{
+    const rb_iseq_t *iseq = def_iseq_ptr(cc->me->def);
+    const int lead_num = iseq->body->param.lead_num;
+    const int opt = calling->argc - lead_num;
+    const int opt_pc = (int)iseq->body->param.opt_table[opt];
+
+    RB_DEBUG_COUNTER_INC(ccf_iseq_opt);
+
+#if USE_OPT_HIST
+    if (opt_pc < OPT_HIST_MAX) {
+        opt_hist[opt]++;
+    }
+    else {
+        opt_hist[OPT_HIST_MAX]++;
+    }
+#endif
+
+    return vm_call_iseq_setup_tailcall(ec, cfp, calling, ci, cc, opt_pc);
+}
+
 static void
 args_setup_kw_parameters(rb_execution_context_t *const ec, const rb_iseq_t *const iseq,
                          VALUE *const passed_values, const int passed_keyword_len, const VALUE *const passed_keywords,
@@ -1909,9 +1933,16 @@ vm_callee_setup_arg(rb_execution_context_t *ec, struct rb_calling_info *calling,
                 argument_arity_error(ec, iseq, argc, lead_num, lead_num + opt_num);
             }
 
-            CC_SET_FASTPATH(cc, vm_call_iseq_setup_normal_opt_start,
-                            !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) &&
-                            !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED));
+            if (LIKELY(!(ci->flag & VM_CALL_TAILCALL))) {
+                CC_SET_FASTPATH(cc, vm_call_iseq_setup_normal_opt_start,
+                                !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) &&
+                                !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED));
+            }
+            else {
+                CC_SET_FASTPATH(cc, vm_call_iseq_setup_tailcall_opt_start,
+                                !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) &&
+                                !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED));
+            }
 
             /* initialize opt vars for self-references */
             VM_ASSERT((int)iseq->body->param.size == lead_num + opt_num);
```

----------------------------------------
Bug #16161: tailcall_optimization may be disabled after r67315
https://bugs.ruby-lang.org/issues/16161#change-81535

* Author: wanabe (_ wanabe)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Before r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67314) [x86_64-linux]
405000450000
```

After r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67315) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

master:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

I think ruby should not raise SystemStackError with tailcall_optimization, should it?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [ruby-core:95239] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
       [not found] <redmine.issue-16161.20190910002817@ruby-lang.org>
  2019-09-10  0:28 ` [ruby-core:94881] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315 s.wanabe
  2019-09-12  9:43 ` [ruby-core:94921] " s.wanabe
@ 2019-10-06  6:19 ` s.wanabe
  2019-10-06  7:00 ` [ruby-core:95241] " s.wanabe
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: s.wanabe @ 2019-10-06  6:19 UTC (permalink / raw)
  To: ruby-core

Issue #16161 has been updated by wanabe (_ wanabe).

Assignee set to ko1 (Koichi Sasada)

----------------------------------------
Bug #16161: tailcall_optimization may be disabled after r67315
https://bugs.ruby-lang.org/issues/16161#change-81914

* Author: wanabe (_ wanabe)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Before r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67314) [x86_64-linux]
405000450000
```

After r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67315) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

master:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

I think ruby should not raise SystemStackError with tailcall_optimization, should it?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:95241] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
       [not found] <redmine.issue-16161.20190910002817@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-10-06  6:19 ` [ruby-core:95239] " s.wanabe
@ 2019-10-06  7:00 ` s.wanabe
  2019-10-06  9:20 ` [ruby-core:95244] " s.wanabe
  2019-10-25  2:10 ` [ruby-core:95536] " s.wanabe
  5 siblings, 0 replies; 6+ messages in thread
From: s.wanabe @ 2019-10-06  7:00 UTC (permalink / raw)
  To: ruby-core

Issue #16161 has been updated by wanabe (_ wanabe).


I created Pull-Request https://github.com/ruby/ruby/pull/2528

----------------------------------------
Bug #16161: tailcall_optimization may be disabled after r67315
https://bugs.ruby-lang.org/issues/16161#change-81916

* Author: wanabe (_ wanabe)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Before r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67314) [x86_64-linux]
405000450000
```

After r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67315) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

master:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

I think ruby should not raise SystemStackError with tailcall_optimization, should it?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:95244] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
       [not found] <redmine.issue-16161.20190910002817@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-10-06  7:00 ` [ruby-core:95241] " s.wanabe
@ 2019-10-06  9:20 ` s.wanabe
  2019-10-25  2:10 ` [ruby-core:95536] " s.wanabe
  5 siblings, 0 replies; 6+ messages in thread
From: s.wanabe @ 2019-10-06  9:20 UTC (permalink / raw)
  To: ruby-core

Issue #16161 has been updated by wanabe (_ wanabe).


Oh I've pushed wrong commit on https://github.com/ruby/ruby/pull/2528 .
I retry to push my working branch on https://github.com/ruby/ruby/pull/2529 .
Sorry!

----------------------------------------
Bug #16161: tailcall_optimization may be disabled after r67315
https://bugs.ruby-lang.org/issues/16161#change-81918

* Author: wanabe (_ wanabe)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Before r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67314) [x86_64-linux]
405000450000
```

After r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67315) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

master:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

I think ruby should not raise SystemStackError with tailcall_optimization, should it?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:95536] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
       [not found] <redmine.issue-16161.20190910002817@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-10-06  9:20 ` [ruby-core:95244] " s.wanabe
@ 2019-10-25  2:10 ` s.wanabe
  5 siblings, 0 replies; 6+ messages in thread
From: s.wanabe @ 2019-10-25  2:10 UTC (permalink / raw)
  To: ruby-core

Issue #16161 has been updated by wanabe (_ wanabe).

Status changed from Open to Closed

Thank you to merge https://github.com/ruby/ruby/pull/2529 on 4ff2c58f919153b9a47f69f855a0b9d2bb0e0bbe.
I confirmed this issue is fixed now.

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-10-25T01:45:46Z master a7ec88ad61) [x86_64-linux]
405000450000

```

----------------------------------------
Bug #16161: tailcall_optimization may be disabled after r67315
https://bugs.ruby-lang.org/issues/16161#change-82312

* Author: wanabe (_ wanabe)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Before r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67314) [x86_64-linux]
405000450000
```

After r67315:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-03-20 trunk 67315) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

master:

```
$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-09-09T23:18:03Z master 3678c37119) [x86_64-linux]
Traceback (most recent call last):
	10080: from -e:1:in `<main>'
	10079: from <compiled>:1:in `foo'
	10078: from <compiled>:1:in `foo'
	10077: from <compiled>:1:in `foo'
	10076: from <compiled>:1:in `foo'
	10075: from <compiled>:1:in `foo'
	10074: from <compiled>:1:in `foo'
	10073: from <compiled>:1:in `foo'
	 ... 10068 levels...
	    4: from <compiled>:1:in `foo'
	    3: from <compiled>:1:in `foo'
	    2: from <compiled>:1:in `foo'
	    1: from <compiled>:1:in `foo'
<compiled>:1:in `foo': stack level too deep (SystemStackError)
```

I think ruby should not raise SystemStackError with tailcall_optimization, should it?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-25  2:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16161.20190910002817@ruby-lang.org>
2019-09-10  0:28 ` [ruby-core:94881] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315 s.wanabe
2019-09-12  9:43 ` [ruby-core:94921] " s.wanabe
2019-10-06  6:19 ` [ruby-core:95239] " s.wanabe
2019-10-06  7:00 ` [ruby-core:95241] " s.wanabe
2019-10-06  9:20 ` [ruby-core:95244] " s.wanabe
2019-10-25  2:10 ` [ruby-core:95536] " s.wanabe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).