ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:95759] [Ruby master Bug#16334] Wrong line numbers for multiline method chains
       [not found] <redmine.issue-16334.20191108151545@ruby-lang.org>
@ 2019-11-08 15:15 ` viuginov.nickolay
  2019-11-08 15:40 ` [ruby-core:95760] " mame
  1 sibling, 0 replies; 2+ messages in thread
From: viuginov.nickolay @ 2019-11-08 15:15 UTC (permalink / raw)
  To: ruby-core

Issue #16334 has been reported by ViugiNick (Nickolay Viuginov).

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

* 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/

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

* [ruby-core:95760] [Ruby master Bug#16334] Wrong line numbers for multiline method chains
       [not found] <redmine.issue-16334.20191108151545@ruby-lang.org>
  2019-11-08 15:15 ` [ruby-core:95759] [Ruby master Bug#16334] Wrong line numbers for multiline method chains viuginov.nickolay
@ 2019-11-08 15:40 ` mame
  1 sibling, 0 replies; 2+ messages in thread
From: mame @ 2019-11-08 15:40 UTC (permalink / raw)
  To: ruby-core

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/

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

end of thread, other threads:[~2019-11-08 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16334.20191108151545@ruby-lang.org>
2019-11-08 15:15 ` [ruby-core:95759] [Ruby master Bug#16334] Wrong line numbers for multiline method chains viuginov.nickolay
2019-11-08 15:40 ` [ruby-core:95760] " mame

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).