Project

General

Profile

Actions

Bug #9759

closed

[TracePoint API] return event missing when raising exception

Added by deivid (David Rodríguez) over 10 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
https://github.com/thoughtbot/factory_girl/blob/master/lib/factory_girl/strategy_syntax_method_registrar.rb
[ruby-core:62096]

Description

I think I found another bug in the TracePoint API, which seems related to #9321. In this case, the failing event is a return event from a method inside of which the exception was generated.

I wrote a failing test case, adapting the code from factory_girl, which is where I first found the strange behaviour.

Thanks a lot in advance!


Files

tracepoint_missing_return_bug.rb (1.37 KB) tracepoint_missing_return_bug.rb deivid (David Rodríguez), 04/19/2014 12:08 PM

Updated by deivid (David Rodríguez) over 10 years ago

Also, I'm not sure whether those [:b_call, :create] and [:b_return, :create] events should be emitted at all. The block is run when defining the method, not when running it... Right?

Updated by ko1 (Koichi Sasada) over 10 years ago

  • Category set to core
  • Assignee set to ko1 (Koichi Sasada)

Updated by ko1 (Koichi Sasada) over 10 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Applied in changeset r45758.


  • vm.c (invoke_block_from_c): add VM_FRAME_FLAG_BMETHOD to record
    it is bmethod frame.
  • vm.c (vm_exec): invoke RUBY_EVENT_RETURN event if rollbacked frame
    is VM_FRAME_FLAG_BMETHOD.
    [Bug #9759]
  • test/ruby/test_settracefunc.rb: add a test for TracePoint/set_trace_func.
  • vm_core.h: renmae rb_thread_t::passed_me to
    rb_thread_t::passed_bmethod_me to clarify the usage.
  • vm_insnhelper.c (vm_call_bmethod_body): use renamed member.

Updated by ko1 (Koichi Sasada) over 10 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: UNKNOWN, 2.1: REQUIRED

It can be reproduced by the following code:

  class C9759
    define_method(:foo){
      raise
    }
  end

  events = []
  obj = C9759.new
  TracePoint.new(:call, :return){|tp|
    events << [tp.event, tp.method_id]
  }.enable{
    obj.foo rescue nil
  }
  p events

I hope this fix will be applied to 2.1.

Updated by deivid (David Rodríguez) over 10 years ago

Thanks!! So happy that this got fixed!! I hope it'll be added to 2.1 too.

Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED to 2.0.0: UNKNOWN, 2.1: DONE

r45758 and r45759 were backported into ruby_2_1 branch at r45928.

Updated by deivid (David Rodríguez) over 10 years ago

Hi @Tomoyuki, thanks a lot for backporting this. May I ask for backdport of r44535 as well? It's a related fix and it would really improve byebug's quality and other programs using the tracepoint api.

Furthermore, both revisions would also be needed in the 2.0 branch.

Thanks a lot!!

Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago

Hello, David.

Sorry for late response.
I'll handle about r44535 at #9321.
Thank you for your notice!

Updated by deivid (David Rodríguez) over 10 years ago

Hi Tomoyuki! I´ll follow up at #9321 then. What about backports to 2.0 branch?

Thanks a lot!

Updated by usa (Usaku NAKAMURA) over 10 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: DONE to 2.0.0: REQUIRED, 2.1: DONE

r45758 is not enough to resolve this problem for ruby_2_0_0.
But I cannot find what is missing.
ko1, do you have any idea?

Updated by deivid (David Rodríguez) over 10 years ago

Yes, maybe he is aware of this because he only asked for backport to the 2.1 branch. Can you help us, ko1?

Updated by usa (Usaku NAKAMURA) about 10 years ago

  • Status changed from Closed to Assigned

(reminder)

Updated by deivid (David Rodríguez) almost 10 years ago

Did you get the chance to have a look at this, ko1? Thanks!

Actions #15

Updated by naruse (Yui NARUSE) almost 7 years ago

  • Target version deleted (2.2.0)
Actions #16

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0