Recursive Rails

I’ve been ploughing through the examples in the Rails book. Until I got to the testing section. In particular, the test_checkout method. I started seeing core dumps. Inspecting the core dump with gdb showed that there was obviously something going wrong recursively.

I had a look in the test.log file and it showed that was calling display_cart continuously in a loop, with an empty set of options. Tracking down a nearby log message, I got looking at components.rb. It was obvious that component_logging was being called with an empty set of optipons. But at this point I was more or less out of my depth (I’ve only just started learning ruby). So I turned to the rails development site for help.

There, a quick search for render_component quickly led me to ticket#2695. Glad to see I’m not the only one having the same problem. It also revealed that it had been fixed in change#2829. I manually patched my installation to do the same thing and everything works fine now.

But what I find really odd is the fact that Ruby will core dump (SIGILL—illegal instruction) when it recurses too deeply. It’s a bit weird that it doesn’t protect against that. Perhaps its just my installation on FreeBSD? I’ll have to test Linux as well. Hmm, there it raises a SystemStackError instead, which is more reasonable. I’ll have to point this out on the freebsd-ports mailing list.