=begin
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:
In message "Re: [ruby-core:21161] [Bug #985] profile lib + iterator => 'NULL pointer given' (ArgumentError)"
on Tue, 6 Jan 2009 08:54:03 +0900, Alex Fenton redmine@ruby-lang.org writes:
|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 '
The direct reason is that rb_sourcefile() returns NULL. The attached
patch will fix the problem, but I am not sure yet why rb_sourcefile()
(and why vm_get_ruby_level_next_cfp) gives us NULL. I hope Koichi has
the answer.