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