2 January 2013

Ruby 1.9.3-p362 Broken?Oopsy!

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.

Bad idea.

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:

https://bugs.ruby-lang.org/issues/7643

When define_method is 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!

Get Scottie Stuff!

Get 10% off EVERYTHING from Wednesday Sept 11th through Friday the 13th with code: S3PT3MB3R !!

Ruby 1.9.3-p362: “Stack level too deep” Error Message is a bug?
Tagged on:         

3 thoughts on “Ruby 1.9.3-p362: “Stack level too deep” Error Message is a bug?

  • 12 January 2013 at 05:24
    Permalink

    I am busy working on a Rails 3.2 app, and am getting similar stack trace errors. Seems to complain about activerecord relation.

    From what I can tell they have done quite a few code optimisations in p362, and the new c code is what is failing (performance when running my rspec tests does seem to be slightly improved). Switching back to p327 gets rid of all the errors I am getting.

    Reply
    • 12 January 2013 at 11:38
      Permalink

      Aha! Good to know. Hopefully this means they will fix the problem quickly.

      Reply
  • 22 January 2014 at 17:20
    Permalink

    I just got burned by this today. Thanks for the post! Going to update to p484

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.