JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6495

java.nio.ByteBuffer.wrap throws java.lang.IndexOutOfBoundsException

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
    • Number of attachments :
      1

      Description

      >jruby -S rails c
      
      
      
      threads = []
      100.times {threads << Thread.new {p YAML.load(ERB.new(File.read(::Devise.ldap_config || "#{Rails.root}/config/ldap.yml")).result)[Rails.env]}}
      
      
      
      java.lang.IndexOutOfBoundsException
              at java.nio.ByteBuffer.wrap(ByteBuffer.java:352)
              at org.jruby.RubyEncoding.decode(RubyEncoding.java:198)
              at org.jruby.RubyString.decodeString(RubyString.java:725)
              at org.jruby.RubyString.toString(RubyString.java:701)
              at org.jruby.RubyString.asJavaString(RubyString.java:1233)
              at org.jruby.ext.psych.PsychParser.parse(PsychParser.java:113)
              at org.jruby.ext.psych.PsychParser$i$1$0$parse.call(PsychParser$i$1$0$parse.gen:65535)
              at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:167)
              at c_3a_.Users.bwalsh.jruby_minus_1_dot_6_dot_7.lib.ruby.$1_dot_9.psych.method__5$RUBY$parse_stream(c:/Users/bwalsh/jruby-1.6.7/lib/ruby/1.9/psych.rb:148)
              at c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__5$RUBY$parse_stream.call(c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__5$RUBY$parse_stream:65535)
              at c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__5$RUBY$parse_stream.call(c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__5$RUBY$parse_stream:65535)
              at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:167)
              at c_3a_.Users.bwalsh.jruby_minus_1_dot_6_dot_7.lib.ruby.$1_dot_9.psych.method__2$RUBY$parse(c:/Users/bwalsh/jruby-1.6.7/lib/ruby/1.9/psych.rb:119)
              at c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__2$RUBY$parse.call(c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__2$RUBY$parse:65535)
              at c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__2$RUBY$parse.call(c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__2$RUBY$parse:65535)
              at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:167)
              at c_3a_.Users.bwalsh.jruby_minus_1_dot_6_dot_7.lib.ruby.$1_dot_9.psych.method__1$RUBY$load(c:/Users/bwalsh/jruby-1.6.7/lib/ruby/1.9/psych.rb:106)
              at c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__1$RUBY$load.call(c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__1$RUBY$load:65535)
              at c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__1$RUBY$load.call(c_3a_$Users$bwalsh$jruby_minus_1_dot_6_dot_7$lib$ruby$$1_dot_9$psych$method__1$RUBY$load:65535)
              at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:167)
              at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
              at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
              at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
              at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
              at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:111)
              at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:212)
              at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:200)
              at org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:131)
              at org.jruby.runtime.Block.call(Block.java:89)
              at org.jruby.RubyProc.call(RubyProc.java:270)
              at org.jruby.RubyProc.call(RubyProc.java:224)
              at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:95)
              at java.lang.Thread.run(Thread.java:662)
      
      irb(main):004:0* 
      

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        I was unable to reproduce this on master or jruby-1_6 branches using the following command line. Something specific to running in the console, maybe?

        $ jruby --1.9 -e "require 'config/application'; str = ERB.new(File.read(::Devise.ldap_config || \"#{Rails.root}/config/ldap.yml\")).result; Thread.abort_on_exception = true; (1..100).map{Thread.new{loop {p YAML.load(str)}}}.map(&:join)"
        
        Show
        Charles Oliver Nutter added a comment - I was unable to reproduce this on master or jruby-1_6 branches using the following command line. Something specific to running in the console, maybe? $ jruby --1.9 -e "require 'config/application'; str = ERB.new(File.read(::Devise.ldap_config || \"#{Rails.root}/config/ldap.yml\")).result; Thread.abort_on_exception = true; (1..100).map{Thread.new{loop {p YAML.load(str)}}}.map(&:join)"
        Hide
        brian walsh added a comment -

        I think your example moves the File.read and ERB.new outside the threads. The thread test was limited to YAML.load

        My test was to reproduce what happens intermittently as the web app runs. Literally to take a line of code from the devise_ldap_authenticatable gem and run it within the threads.

        I'm unclear if this is a coding problem or a jruby problem. Working with the ldap gem guys,it appears to work with MRI. It seems right now as if the problem is with ERB.new()?

        https://github.com/cschiewek/devise_ldap_authenticatable/issues/73

        Show
        brian walsh added a comment - I think your example moves the File.read and ERB.new outside the threads. The thread test was limited to YAML.load My test was to reproduce what happens intermittently as the web app runs. Literally to take a line of code from the devise_ldap_authenticatable gem and run it within the threads. I'm unclear if this is a coding problem or a jruby problem. Working with the ldap gem guys,it appears to work with MRI. It seems right now as if the problem is with ERB.new()? https://github.com/cschiewek/devise_ldap_authenticatable/issues/73
        Hide
        brian walsh added a comment -

        Confirmed with ldap_authenticatable team that the problem is within ERB.new or ERB.new().result.

        Show
        brian walsh added a comment - Confirmed with ldap_authenticatable team that the problem is within ERB.new or ERB.new().result.
        Hide
        Charles Oliver Nutter added a comment -

        Let's be optimistic and say this is fixed.

        Since this bug was filed, we've fixed literally dozens of encoding issues, including many that would trigger IndexOutOfBounds.

        If you can reproduce it, please reopen

        Show
        Charles Oliver Nutter added a comment - Let's be optimistic and say this is fixed. Since this bug was filed, we've fixed literally dozens of encoding issues, including many that would trigger IndexOutOfBounds. If you can reproduce it, please reopen

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            brian walsh
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: