Project

General

Profile

Actions

Bug #5519

closed

Enumerator#next skips c-return hooks

Added by YenTheFirst (T S) about 13 years ago. Updated about 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
Backport:
[ruby-core:40538]

Description

In some cases, especially using #next, c-calls are traced, but corresponding c-returns are not.

tracing this snippet:
a=[1,2,3,4].to_enum
b=a.next

produces this output:

c-return test4.rb:3 set_trace_func Kernel
line test4.rb:4
c-call test4.rb:4 to_enum Kernel
c-return test4.rb:4 to_enum Kernel
line test4.rb:5
c-call test4.rb:5 next Enumerator
c-call test4.rb:5 proc Kernel
c-return test4.rb:5 proc Kernel
c-call :0 each Enumerator
c-call :0 each Array
c-return test4.rb:5 next Enumerator

Enumerator#each and Array#each are c-called, but the next return jumps back up to Enumerator#next.

I get the same result on 1.9.2-p290, 1.9.2-head(r32926), and 1.9.3-head(r33569)

Updated by kernigh (George Koehler) about 13 years ago

=begin
This trace seems correct to me. There is no c-return because Array#each and Enumerator#each are not returning. To see the c-return, you call ((b.next)) 4 more times. Array#each and Enumerator#each both c-return soon before Enumerator#next raises StopIteration.

I am not sure how this works, but I guess that Enumerator#each runs on a different Fiber with a separate call stack.
=end

Updated by ko1 (Koichi Sasada) almost 13 years ago

  • Status changed from Open to Feedback

Updated by mame (Yusuke Endoh) about 12 years ago

  • Status changed from Feedback to Rejected

kernigh is right; this is a spec. Closing.

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0