On 25 December 2012, Ruby version 1.9.3-p362 was released. Is that dedication, or what?
Yesterday, I decided to upgrade to this new version of Ruby that contains only bug fixes.
Sure, the site loads… But if you try to create a new record via the front-end UI, it craps out with an Internal Server Error.
Digging a bit deeper, it seems this new Ruby version causes a “stack level too deep” error in /active_record/transactions.rb – at least when using Rails 2.3.x.
So, how do we fix this little problem?
Check this out:
define_methodis used within the refine block argument, calls to super will result in a stack level too deep. Definitions with def can call super without problems.
Now, the target version for this bug is Ruby 2.0.0. I hate these bug-tracking sites, because I can never figure out exactly which version contains the reported bug. But I didn’t have any other leads, so…
When I look at the transactions.rb and associated files/classes, I’m not seeing any refine/super stuff. But I am seeing the stack level too deep error. I didn’t really expect to find any “refine” stuff in Rails 2.3 code, since Refinements appear to have been introduced into Ruby 1.9, and the Rails peeps don’t officially want you to use Rails 2.3 with any Ruby version higher than 1.8.
However, ff you want to, you can stick with Rails 2.3 and still get the Ruby 1.9 goodness. It’s zippy!
Now, granted, “stack level too deep” can be caused by a whole lot of different things. Usually, unintended recursion in one’s code is the culprit. But in my case, we’re talking about an app whose codebase hasn’t changed recently. Until the Ruby upgrade, it had been working just fine. I also managed to replicate the problem on a different server with a different app (also based on Rails 2.3.x).
So, I don’t know exactly where the problem is.
But I do know that if you’re using Rails 2.3.x (and possibly even Rails 3.x), and if you see this “stack level too deep” issue with the latest version of Ruby, try reverting back to 1.9.3-p327.
Switching back to p327 instantly resolved the problem for me.
If you have seen this error and have any further info on it, do drop me a line in the comments below. I’m all ears!
UPDATE – 20 January 2013: Good news: Ruby 1.9.3-p374 has been released, and it fixed this problem for me!