Project

General

Profile

Actions

Bug #18646

closed

Inconsistent behavior for the targeted TracePoints in ruby 2.6-2.7 and 3+

Added by hurricup (Alexandr Evstigneev) about 2 years ago. Updated about 2 years ago.

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

Description

Ruby 2.6 introduced the API for targeted tracepoints.
But for some reason, before ruby 3.0, tracepoints looks exclusive per iseq.

Consider an example:

def somemethod
  puts 1
  puts 2
  puts 3
end

tp1 = TracePoint.new(:line) { |tp| puts 'This is tp1'}
tp2 = TracePoint.new(:line) { |tp| puts 'This is tp2'}

method_iseq = RubyVM::InstructionSequence.of(method :somemethod)
tp1.enable(target: method_iseq, target_line: 2)
tp2.enable(target: method_iseq, target_line: 4)
somemethod

Ruby 2.6-2.7 prints :

1
2
This is tp2
3

And this is unexpected, because we have 2 tracepoints and expecting both to work. But actually, only last enabled does.

Ruby 3+ work as expected:

This is tp1
1
2
This is tp2
3

Would be really nice to have consistent 3+ behavior everywhere


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #17302: The TracePoint API does not allow setting multiple line traces within the same method (ISEQ)ClosedActions

Updated by hurricup (Alexandr Evstigneev) about 2 years ago

Looks like this was fixed in https://bugs.ruby-lang.org/issues/17302
Any plans to backport to 2.6/2.7?

Actions #2

Updated by Eregon (Benoit Daloze) about 2 years ago

  • Related to Bug #17302: The TracePoint API does not allow setting multiple line traces within the same method (ISEQ) added

Updated by Eregon (Benoit Daloze) about 2 years ago

  • Status changed from Open to Closed

I've set the backport field for https://bugs.ruby-lang.org/issues/17302.
For 2.6 it's unlikely given it's soon EOL.
In any case it's up to branch maintainers.

I'll close this since everything is tracked by the backport field now.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0