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].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>

Comments and changes to this ticket

  • Nobuhiro IMAI

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

    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,

  • 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/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.

  • 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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages