ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: s.wanabe@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95241] [Ruby master Bug#16161] tailcall_optimization may be disabled after r67315
Date: Sun, 06 Oct 2019 07:00:48 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-81916.20191006070047.4f9c7d0e8c3f453e@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16161.20190910002817@ruby-lang.org

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/

  parent reply	other threads:[~2019-10-06  7:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 ` s.wanabe [this message]
2019-10-06  9:20 ` [ruby-core:95244] " s.wanabe
2019-10-25  2:10 ` [ruby-core:95536] " s.wanabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-81916.20191006070047.4f9c7d0e8c3f453e@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).