Backport #8489

Tracepoint API: B_RETURN_EVENT not triggered when "next" used

Added by David Rodríguez 11 months ago. Updated 10 months 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 (BRETURNEVENT) is not triggered. For example, I would expect the same number of BCALLEVENT and BRETURNEVENT in the piece of code:

traceBlocks = TracePoint.new(:bcall, :breturn) 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 BCALLEVENT and 1 BRETURNEVENT. 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 41319
Added by Tomoyuki Chikanaga 10 months 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 10 months 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 10 months 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 (rbiseqcompilenode): fix location of a `trace' instruction (breturn event). ruby-trunk - Bug #8489
  • test/ruby/test_settracefunc.rb: add a test.

#3 Updated by Koichi Sasada 10 months 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: BRETURNEVENT 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 (BRETURNEVENT) is not triggered. For example, I would expect the same number of BCALLEVENT and BRETURNEVENT in the piece of code:

traceBlocks = TracePoint.new(:bcall, :breturn) 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 BCALLEVENT and 1 BRETURNEVENT. 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 10 months 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 10 months 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 10 months 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 10 months ago

Sweet, thanks a lot guys!

#8 Updated by Tomoyuki Chikanaga 10 months ago

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

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 10 months 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