This project is archived and is in readonly mode.

#2942 ✓invalid
Takuto Wada

Enumerable::Enumerator#next causes 'stack level too deep' since ActiveSupport 2.3.3

Reported by Takuto Wada | July 23rd, 2009 @ 10:30 AM | in 2.3.4

Enumerator#next with AS causes an error on Ruby 1.8.7.
It happens on 2.3.3 and edge. Reproduction case is as follows.

$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'active_support'
=> true
irb(main):003:0> %w[foo bar baz]
SystemStackError: stack level too deep
       from (irb):3:in `next'
       from (irb):3
       from /usr/lib/ruby/1.8/rubygems/requirement.rb:29
irb(main):004:0> require 'active_support/version'
=> []
irb(main):005:0> p ActiveSupport::VERSION::STRING
=> nil

Comments and changes to this ticket

  • Nobuhiro IMAI

    Nobuhiro IMAI July 23rd, 2009 @ 02:33 PM


    I found a kind of reason for this behavior.

    $ irb -f --simple-prompt
    >> require "rubygems"
    => true
    >> require "active_support"
    => true
    >> $:.reject{|path| Dir.glob(File.join(path, "generator.{rb,so}")).empty?}
    => ["/home/nov/gems/gems/json-1.1.7/ext/json/ext", "/usr/lib/ruby/1.8"]
    $ ls -1 /home/nov/gems/gems/json-1.1.7/ext/json/ext/generator.* /usr/lib/ruby/1.8/generator.*

    Enumerable::Enumerator#next is implemented by using "generator" feature,
    and then expected generator.rb but actually loaded from json.


    $ cat 2942.rb 
    require "rubygems"
    gem "activesupport", ARGV.first
    require "active_support"
    puts $:
    $ diff -u <(ruby 2942.rb 2.3.2) <(ruby 2942.rb 2.3.3)
    --- /dev/fd/63  2009-07-23 22:26:35.771825193 +0900
    +++ /dev/fd/62  2009-07-23 22:26:35.807824193 +0900
    @@ -1,11 +1,15 @@

    Hmm, it seems that the JSON.backend mechanism may be related, I guess.


  • Michael Koziarski

    Michael Koziarski August 3rd, 2009 @ 06:24 AM

    • Assigned user set to “Jeremy Kemper”
    • Milestone changed from 2.x to 2.3.4
  • Jeremy Kemper

    Jeremy Kemper August 3rd, 2009 @ 10:54 PM

    • State changed from “new” to “invalid”

    This is a bug with the json gem polluting the load path: /home/nov/gems/gems/json-1.1.7/ext/json/ext/

    Active Support includes the json gem if it's available, exposing this issue as a side effect. To work around, uninstall the json gem.

  • Bodaniel Jeanes

    Bodaniel Jeanes January 14th, 2010 @ 05:18 AM

    Actually instead of uninstalling the json gem, you can workaround it (temporarily) by requiring "generator.rb" yourself before using the #next method. Just be sure to include the .rb in the require statement so it specifically loads the rb version (the json one will be generator.{so,dll,bundle,dylib})

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>