[ruby-core:95536] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
From:
s.wanabe@...
Date:
2019-10-25 02:10:03 UTC
List:
ruby-core #95536
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/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>