Backport #8489

Tracepoint API: B_RETURN_EVENT not triggered when "next" used

Added by David Rodríguez almost 2 years ago. Updated almost 2 years ago.

[ruby-core:55305]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

I'm using the Tracepoint API in my gem and I notice that when the keyword next is used inside a block, a block return event (B_RETURN_EVENT) is not triggered. For example, I would expect the same number of B_CALL_EVENT and B_RETURN_EVENT in the piece of code:

traceBlocks = TracePoint.new(:b_call, :b_return) do |tp|
p "#{tp.event == :b_call ? 'Block called' : 'Block returned'}"
end.enable do
3.times do
next
end
end

but instead there are 4 B_CALL_EVENT and 1 B_RETURN_EVENT. As I understand it, "next" causes the block to exit immediately, returning control to the iterator, which may invoke the block again, so I would say a block return event should be triggered.

Thanks a lot.

Associated revisions

Revision 41300
Added by Koichi Sasada almost 2 years ago

  • compile.c (rb_iseq_compile_node): fix location of a `trace' instruction (b_return event). ruby-trunk - Bug #8489
  • test/ruby/test_settracefunc.rb: add a test.

Revision 41319
Added by Tomoyuki Chikanaga almost 2 years ago

merge revision(s) 41300: [Backport #8489]

* compile.c (rb_iseq_compile_node): fix location of a `trace'
  instruction (b_return event).
   [ruby-trunk - Bug #8489]
  (need a backport to 2.0.0?)

* test/ruby/test_settracefunc.rb: add a test.

History

#1 Updated by David Rodríguez almost 2 years ago

This is the "no replies after 10 days reminder".

If this is not a priority right now, I can try have a look at this myself (not sure how it will go though...).

Thanks again.

#2 Updated by Koichi Sasada almost 2 years ago

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

This issue was solved with changeset r41300.
David, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • compile.c (rb_iseq_compile_node): fix location of a `trace' instruction (b_return event). ruby-trunk - Bug #8489
  • test/ruby/test_settracefunc.rb: add a test.

#3 Updated by Koichi Sasada almost 2 years ago

Thank youf for your report.
I fixed it. Could you check it?

(2013/06/14 17:55), deivid (David Rodríguez) wrote:

Issue #8489 has been updated by deivid (David Rodríguez).

This is the "no replies after 10 days reminder".

If this is not a priority right now, I can try have a look at this myself (not sure how it will go though...).

Thanks again.

Bug #8489: Tracepoint API: B_RETURN_EVENT not triggered when "next" used
https://bugs.ruby-lang.org/issues/8489#change-39925

Author: deivid (David Rodríguez)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0p201 (2013-06-04) [i686-linux]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN

I'm using the Tracepoint API in my gem and I notice that when the keyword next is used inside a block, a block return event (B_RETURN_EVENT) is not triggered. For example, I would expect the same number of B_CALL_EVENT and B_RETURN_EVENT in the piece of code:

traceBlocks = TracePoint.new(:b_call, :b_return) do |tp|
p "#{tp.event == :b_call ? 'Block called' : 'Block returned'}"
end.enable do
3.times do
next
end
end

but instead there are 4 B_CALL_EVENT and 1 B_RETURN_EVENT. As I understand it, "next" causes the block to exit immediately, returning control to the iterator, which may invoke the block again, so I would say a block return event should be triggered.

Thanks a lot.

--
// SASADA Koichi at atdot dot net

#4 Updated by Tomoyuki Chikanaga almost 2 years ago

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

#5 Updated by David Rodríguez almost 2 years ago

Just tried it @ko1, it works perfectly!

@nagachika, forgive my ignorance but "Backport to 2.0.0" means the patch will be released with the next patchlevel release?

Thanks a lot!!

#6 Updated by Zachary Scott almost 2 years ago

On Sat, Jun 15, 2013 at 12:41 AM, deivid (David Rodríguez)
deivid.rodriguez@gmail.com wrote:

@nagachika, forgive my ignorance but "Backport to 2.0.0" means the patch will be released with the next patchlevel release?

Yes, nagachika-san is the 2.0.0 release manager, he will backport this
for the next patchlevel release of ruby 2.0.0 series.

#7 Updated by David Rodríguez almost 2 years ago

Sweet, thanks a lot guys!

#8 Updated by Tomoyuki Chikanaga almost 2 years ago

  • Assignee set to Tomoyuki Chikanaga
  • Status changed from Closed to Assigned
  • Project changed from Ruby trunk to Backport200
  • Tracker changed from Bug to Backport

Hello, deivid.
Never mind. It's my work to check if a changeset need to backport :)

And I'm going to backport r41300.

#9 Updated by Tomoyuki Chikanaga almost 2 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r41319.
David, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 41300: [Backport #8489]

* compile.c (rb_iseq_compile_node): fix location of a `trace'
  instruction (b_return event).
   [ruby-trunk - Bug #8489]
  (need a backport to 2.0.0?)

* test/ruby/test_settracefunc.rb: add a test.

Also available in: Atom PDF