Project

General

Profile

Actions

Bug #17302

closed

The TracePoint API does not allow setting multiple line traces within the same method (ISEQ)

Added by liran.last@gmail.com (Liran Haimovitch) over 3 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:100684]

Description

While setting a tracepoint for a line for the second time within a method, the first one turns off.

I believe this is because the encoded_iseq_trace_instrument function resets the trace value of an instruction rather than just turning it on if needed: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3178

And it is unconditionally called, not limited to the correct line: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3219


Files

my_test.rb (790 Bytes) my_test.rb liran.last@gmail.com (Liran Haimovitch), 11/01/2020 11:53 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #18646: Inconsistent behavior for the targeted TracePoints in ruby 2.6-2.7 and 3+ClosedActions

Updated by liran.last@gmail.com (Liran Haimovitch) over 3 years ago

(Liran Haimovitch) wrote:

When setting a second line tracepoint within a method the first one will be turned off.

I believe this is due to the fact that the encoded_iseq_trace_instrument function resets the trace value of an instruction rather then just turn it on if needed - https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3178

And it is unconditionally called, not limited to the correct line: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3219

Attaching a short file to reproduce the bug, based on the existing enable_spec.rb in the Ruby repo.

Updated by liran.last@gmail.com (Liran Haimovitch) over 3 years ago

(Liran Haimovitch) wrote in #note-1:

(Liran Haimovitch) wrote:

When setting a second line tracepoint within a method the first one will be turned off.

I believe this is due to the fact that the encoded_iseq_trace_instrument function resets the trace value of an instruction rather then just turn it on if needed - https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3178

And it is unconditionally called, not limited to the correct line: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3219

Attaching a short file to reproduce the bug, based on the existing enable_spec.rb in the Ruby repo.

After some additional investigation, it seems that when adding multiple breakpoints to the same method (ISEQ) only the last one will apply. BUT, if I disable even one of them, all the breakpoints that are left enabled will work simultaneously.

Actions #3

Updated by sawa (Tsuyoshi Sawada) over 3 years ago

  • Description updated (diff)
Actions #4

Updated by ko1 (Koichi Sasada) over 3 years ago

  • Status changed from Open to Closed

Applied in changeset git|084e7e31b257f6ac859769553b4c1c6ca2930152.


remain enabled and line specified trace points

If two or more tracepoints enabled with the same target and with
different target lines, the only last line is activated.
This patch fixes this issue by remaining existing trace instructions.
[Bug #17302]

Actions #5

Updated by Eregon (Benoit Daloze) about 2 years ago

  • Related to Bug #18646: Inconsistent behavior for the targeted TracePoints in ruby 2.6-2.7 and 3+ added
Actions #6

Updated by Eregon (Benoit Daloze) about 2 years ago

  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN to 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONTNEED, 3.1: DONTNEED

Updated by Eregon (Benoit Daloze) about 2 years ago

Backport was requested in https://bugs.ruby-lang.org/issues/18646, and I adjusted the Backport field for it.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0