From: Koichi Sasada Date: 2012-03-11T16:24:50+09:00 Subject: [ruby-core:43196] [ruby-trunk - Bug #5473][Assigned] Raise in method_missing causes infinite loop Issue #5473 has been updated by Koichi Sasada. Status changed from Open to Assigned Assignee set to Koichi Sasada ---------------------------------------- Bug #5473: Raise in method_missing causes infinite loop https://bugs.ruby-lang.org/issues/5473 Author: Peter Vanbroekhoven Status: Assigned Priority: Normal Assignee: Koichi Sasada Category: Target version: ruby -v: ruby 1.9.3dev (2011-10-11 revision 33457) [i386-darwin9.8.0] The following code causes an infinite loop: class ::Object def method_missing(m, *a, &b) raise ArgumentError.new("haha") end end 1.foo This is due to the raise calling to_str on the exception, which isn't defined. So a method_missing that also covers the Exception class and that contains a raise (at least the version with one argument) causes an infinite loop. I'm a bit hesitant to call this a bug, except that the pattern above happened in code that works on Ruby 1.8 and breaks on 1.9. -- http://bugs.ruby-lang.org/