Bug #985: profile lib + iterator => 'NULL pointer given' (ArgumentError)
http://redmine.ruby-lang.org/issues/show/985

Author: Alex Fenton
Status: Open, Priority: High
Reproducible Version: 1.9.1 RC1

This simple piece of code works as expected:

iter = 'abc'.each_char
p iter.next
=> "a"

However, if the profile library is required before this (either by -rprofile on the command line or require 'profile') it crashes with an unexpected 'NULL pointer given' error:

ruby -rprofile bug.rb 
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
  0.00     0.00      0.00        2     0.00     0.00  IO#set_encoding
  0.00     0.00      0.00        1     0.00     0.00  String#each_char
  0.00     0.00      0.00        1     0.00     0.00  Kernel.proc
  0.00     0.00      0.00        1     0.00     0.00  Exception#backtrace
  0.00     0.00      0.00        1     0.00     0.00  Exception#set_backtrace
  0.00     0.01      0.00        1     0.00    10.00  #toplevel
bug.rb:2:in `next': NULL pointer given (ArgumentError)
	from bug.rb:2:in `<main>'

Thanks.


----------------------------------------
http://redmine.ruby-lang.org