undefined method `to_s' in graph_html_printer.rb:56:in `inspect'

71 views
Skip to first unread message

Craig

unread,
May 28, 2012, 1:15:18 PM5/28/12
to ruby optimization
Hi there. I'm getting this error when sending results to a
GraphHTMLPrinter:

NoMethodError (undefined method `to_s' for #<Class:0x00000104f824d8>):
ruby-prof (0.11.2) lib/ruby-prof/printers/graph_html_printer.rb:
56:in `inspect'
ruby-prof (0.11.2) lib/ruby-prof/printers/graph_html_printer.rb:
56:in `full_name'
ruby-prof (0.11.2) lib/ruby-prof/printers/graph_html_printer.rb:
56:in `create_link'
(erb):148:in `block (3 levels) in print'
(erb):137:in `each'
(erb):137:in `block (2 levels) in print'
(erb):96:in `reverse_each'
(erb):96:in `block in print'
(erb):74:in `each'
(erb):74:in `print'
/Users/craig/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/erb.rb:753:in
`eval'
/Users/craig/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/erb.rb:753:in
`result'
ruby-prof (0.11.2) lib/ruby-prof/printers/graph_html_printer.rb:
44:in `print'

I dug into the Ruby code of ruby-prof a bit, but discovered that the
error is being thrown down in the native code. It's being thrown by a
call to MethodInfo.full_name, but I couldn't determine what the
MethodInfo was wrapping.

Catching the error in full_name works around it, but doesn't tell me
anything about what's causing it:

alias_method :old_full_name, :full_name
def full_name
begin
old_full_name
rescue NoMethodError
"[Unknown]"
end
end

Any idea what's causing this, or how I can dig deeper into debugging
it?

Thanks,

Craig Walker
SoftCraft Development

Roger Pack

unread,
May 28, 2012, 10:32:18 PM5/28/12
to ruby-opt...@googlegroups.com
Odd.

Class.new.to_s
=> "#<Class:0x0000000203d868>"

so it "should" work...
is it possible to easily reproduce?
-r

Craig Walker

unread,
May 28, 2012, 10:37:06 PM5/28/12
to ruby-opt...@googlegroups.com
> so it "should" work...

Yup, but it's an odd beast all around.

> is it possible to easily reproduce?

Not terribly; I don't know the circumstances that cause it. I added
debugging into create_link and saw that the method is being called
successfully dozens of times in my test case (for various different
classes/methods). I don't know on which method it's choking, because
the thing that I'd call to discover the target (full_name) is what's
failing in the first place. :-P

Do you have any ideas on how to find out what class & method is wrapped?

Craig

Roger Pack

unread,
May 28, 2012, 10:51:54 PM5/28/12
to ruby-opt...@googlegroups.com
What about older versions like 0.9'ish?
Reply all
Reply to author
Forward
0 new messages