ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / Atom feed
From: mame@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95760] [Ruby master Bug#16334] Wrong line numbers for multiline method chains
Date: Fri, 08 Nov 2019 15:40:30 +0000 (UTC)
Message-ID: <redmine.journal-82578.20191108154029.ffc9e1ad5d5aa484@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-16334.20191108151545@ruby-lang.org>

Issue #16334 has been updated by mame (Yusuke Endoh).


A new line number counting mechanism was introduced at 2.6.  The patch would be too big to backport to 2.5.  @usa, what do you think?

----------------------------------------
Bug #16334: Wrong line numbers for multiline method chains 
https://bugs.ruby-lang.org/issues/16334#change-82578

* Author: ViugiNick (Nickolay Viuginov)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
I faced a strange distribution of line numbers in bytecode for multiline expressions like this:
```
class Test
  def method1
    self
  end

  def method2
    self
  end

  def method3
    true
  end
end
def hello
  Test.new #bp here
      .method1 #bp here
      .method2 #bp here
      .method3 #bp here
end
```
2.3.7 bytecode:
```
== disasm: #<ISeq:hello@/home/viuignick/.RubyMine2019.2/config/scratches/scratch.rb>
0000 trace            8                                               (  14)
0002 trace            1                                               (  18)
0004 getinlinecache   11, <is:0>                                      (  15)
0007 getconstant      :Test
0009 setinlinecache   <is:0>
0011 opt_send_without_block <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>(  16)
0014 opt_send_without_block <callinfo!mid:method1, argc:0, ARGS_SIMPLE>, <callcache>(  17)
0017 opt_send_without_block <callinfo!mid:method2, argc:0, ARGS_SIMPLE>, <callcache>(  18)
0020 opt_send_without_block <callinfo!mid:method3, argc:0, ARGS_SIMPLE>, <callcache>
0023 trace            16                                              (  19)
0025 leave                                                            (  18)
```
As you can see there is no trace line-event instuction for line №15, because of that debuggers will not stop there. Furthermore call of the method `new` is on the line #16(actually 15), method method1 is on the line 17(actually 16), method2 is on the line 18 (actually 19)

2.5.4 bytecode
```
0000 getinlinecache   7, <is:0>                                       (  15)[LiCa]
0003 getconstant      :Test
0005 setinlinecache   <is:0>
0007 opt_send_without_block <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>(  16)
0010 opt_send_without_block <callinfo!mid:method1, argc:0, ARGS_SIMPLE>, <callcache>(  17)
0013 opt_send_without_block <callinfo!mid:method2, argc:0, ARGS_SIMPLE>, <callcache>(  18)
0016 opt_send_without_block <callinfo!mid:method3, argc:0, ARGS_SIMPLE>, <callcache>
0019 leave                                                            (  19)[Re]
```
The same situation to 2.5.*

for ruby versions > 2.5.0 work fine:
```
== disasm: #<ISeq:hello@/home/viuignick/.RubyMine2019.2/config/scratches/scratch.rb:14 (14,0)-(19,3)> (catch: FALSE)
0000 opt_getinlinecache           7, <is:0>                           (  15)[LiCa]
0003 getconstant                  :Test
0005 opt_setinlinecache           <is:0>
0007 opt_send_without_block       <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>
0010 opt_send_without_block       <callinfo!mid:method1, argc:0, ARGS_SIMPLE>, <callcache>(  16)
0013 opt_send_without_block       <callinfo!mid:method2, argc:0, ARGS_SIMPLE>, <callcache>(  17)
0016 opt_send_without_block       <callinfo!mid:method3, argc:0, ARGS_SIMPLE>, <callcache>(  18)
0019 leave                                                            (  19)[Re]
```



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

      parent reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-16334.20191108151545@ruby-lang.org>
2019-11-08 15:15 ` [ruby-core:95759] " viuginov.nickolay
2019-11-08 15:40 ` mame [this message]

Reply instructions:

You may reply publically 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-82578.20191108154029.ffc9e1ad5d5aa484@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

ruby-core@ruby-lang.org archive (unofficial mirror)

Archives are clonable: git clone --mirror https://public-inbox.org/ruby-core

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.core
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.core
	nntp://news.gmane.org/gmane.comp.lang.ruby.core

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git