Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#2942

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].each.next
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
"2.3.3"
=> nil
irb(main):006:0>

Reported by Takuto Wada · July 23rd, 2009 @ 10:30 AM

State: invalid
Milestone: 2.3.4
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Nobuhiro IMAI
    Nobuhiro IMAI

    Hello,

    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.*
    /home/nov/gems/gems/json-1.1.7/ext/json/ext/generator.so
    /usr/lib/ruby/1.8/generator.rb
    

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

    See: http://redmine.ruby-lang.org/repositories/revision/ruby-187?rev=15954

    $ 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 @@
    -/home/nov/gems/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib
    -/home/nov/gems/gems/activesupport-2.3.2/lib/active_support/vendor/tzinfo-0.3.12
    -/home/nov/gems/gems/activesupport-2.3.2/lib/active_support/vendor/memcache-client-1.6.5
    -/home/nov/gems/gems/activesupport-2.3.2/lib/active_support/vendor/builder-2.1.2
    -/home/nov/gems/gems/activesupport-2.3.2/bin
    -/home/nov/gems/gems/activesupport-2.3.2/lib
    +/home/nov/gems/gems/activesupport-2.3.3/lib/active_support/vendor/i18n-0.1.3/lib
    +/home/nov/gems/gems/activesupport-2.3.3/lib/active_support/vendor/tzinfo-0.3.12
    +/home/nov/gems/gems/activesupport-2.3.3/lib/active_support/vendor/memcache-client-1.7.4
    +/home/nov/gems/gems/activesupport-2.3.3/lib/active_support/vendor/builder-2.1.2
    +/home/nov/gems/gems/activesupport-2.3.3/bin
    +/home/nov/gems/gems/activesupport-2.3.3/lib
     /home/nov/gems/gems/hpricot-0.8.1/bin
     /home/nov/gems/gems/hpricot-0.8.1/lib
    +/home/nov/gems/gems/json-1.1.7/bin
    +/home/nov/gems/gems/json-1.1.7/ext/json/ext
    +/home/nov/gems/gems/json-1.1.7/ext
    +/home/nov/gems/gems/json-1.1.7/lib
     /usr/local/lib/site_ruby/1.8
     /usr/local/lib/site_ruby/1.8/i486-linux
     /usr/local/lib/site_ruby/1.8/i386-linux
    

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

    Thanks,

    July 23rd, 2009 @ 02:33 PM

  2. Michael Koziarski
    Michael Koziarski
    • Assigned user set to Jeremy Kemper
    • Milestone changed from 2.x to 2.3.4

    August 3rd, 2009 @ 06:24 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • 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/generator.so

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

    August 3rd, 2009 @ 10:54 PM

  4. Bodaniel Jeanes
    Bodaniel Jeanes

    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})

    January 14th, 2010 @ 05:18 AM