Project

General

Profile

Actions

Bug #21338

closed

TracePoint Not Triggered for Kernel#block_given?

Added by cfis (Charlie Savage) 1 day ago. Updated about 20 hours ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [x86_64-linux]
[ruby-core:122091]

Description

When updating ruby-prof for Ruby 3.4, various tests now fail because a method enter/leave tracepoint is not triggered for Kernel#block_given? For example:

https://github.com/ruby-prof/ruby-prof/blob/master/test/line_number_test.rb#L184

In 3.3 a tracepoint was triggered but not in earlier Ruby versions.

Updated by alanwu (Alan Wu) 1 day ago

  • Status changed from Open to Rejected

It's a C method in 3.4, so you can listen for :c_call:

ruby -ve 'TracePoint.new(:c_call) { p _1 }.enable { block_given? }'

Wether something is a C or Ruby method is not something we guarantee to be stable, though, so it's not a bug now that a different event fires.

Updated by cfis (Charlie Savage) about 20 hours ago ยท Edited

ruby-prof does listen for C calls. See:

https://github.com/ruby-prof/ruby-prof/blob/master/ext/ruby_prof/rp_profile.c#L337

void prof_install_hook(VALUE self)
{
    prof_profile_t* profile = prof_get_profile(self);

    VALUE event_tracepoint = rb_tracepoint_new(Qnil,
                                               RUBY_EVENT_CALL | RUBY_EVENT_RETURN |
                                               RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN |
                                               RUBY_EVENT_LINE,
                                               prof_event_hook, profile);

Once again, this is change in behavior between 3.3 and 3.4. Was it intentional?

Actions

Also available in: Atom PDF

Like0
Like0Like0