ArrayIndexOutOfBoundsException in RubyString.cat
------------------------------------------------

                 Key: JRUBY-4592
                 URL: http://jira.codehaus.org/browse/JRUBY-4592
             Project: JRuby
          Issue Type: Bug
    Affects Versions: JRuby 1.4
         Environment: Ubuntu 9.10, x86

jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2010-02-03 6586) (Java HotSpot(TM) 
Client VM 1.6.0_15) [i386-java]
            Reporter: Neil Brown
            Assignee: Thomas E Enebo


I have an uncaught Java exception occurring in JRuby.  This is for a Ruby on 
Rails installation running on JRuby, and the exception stops the entire server 
responding until manually restarted, which is obviously an issue for us.  
Here's what I can discern of the bug: we use Maruku 
(http://maruku.rubyforge.org/) to process Markdown into HTML.  Markdown feeds 
the HTML into REXML (http://www.germane-software.com/software/rexml/) to parse 
it.  If you feed the libraries malformed HTML (e.g. an unclosed tag), it 
returns output just fine (with an error in the HTML output).  If you feed it 
unicode characters (e.g. a non-exotic 2-byte UTF-8 character such as an o with 
an umlaut), it is fine.  If you feed it malformed HTML with a unicode 
character, JRuby throws an uncaught ArrayOutOfBoundsException arising in the 
RubyString.cat method where it calls System.arraycopy.  (I wonder if this is an 
issue of number-of-characters versus number-of-bytes?)  Here's the Java stack 
trace:

begin = 0
len = 2
bytes = [-61]
0, 2, [-61]
Exception in thread "Thread-7" java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at org.jruby.RubyString.cat(RubyString.java:1080)
        at org.jruby.RubyString.inspectCommon(RubyString.java:2154)
        at org.jruby.RubyString.inspect(RubyString.java:2093)
        at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.jruby.internal.runtime.methods.ReflectedJavaMethod.call(ReflectedJavaMethod.java:108)
        at 
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:172)
        at 
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:168)
        at 
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:107)
        at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:61)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.EvStrNode.interpret(EvStrNode.java:86)
        at org.jruby.ast.DStrNode.appendToString(DStrNode.java:86)
        at org.jruby.ast.DStrNode.buildDynamicString(DStrNode.java:76)
        at org.jruby.ast.DStrNode.interpret(DStrNode.java:68)
        at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.ast.IfNode.interpret(IfNode.java:117)
        at org.jruby.ast.IfNode.interpret(IfNode.java:119)
        at org.jruby.ast.IfNode.interpret(IfNode.java:119)
        at org.jruby.ast.IfNode.interpret(IfNode.java:119)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.WhenOneArgNode.when(WhenOneArgNode.java:49)
        at org.jruby.ast.CaseNode.interpret(CaseNode.java:133)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.ast.UntilNode.interpret(UntilNode.java:120)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at 
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:173)
        at 
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
        at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.ast.WhileNode.interpret(WhileNode.java:131)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
...

The whole trace is about 100-200 lines of similar information.  I can't easily 
track down the problem any further because the Java stack trace doesn't tell me 
anything about which bit of Ruby code caused the problem (what flags could I 
set to allow me to do so?).  I can reproduce this error consistently and easily 
so I'm happy to help track down the problem if someone can direct me as to how.

I did wonder if I should report this to the Maruku/REXML maintainers instead -- 
I would have if it gave a Ruby exception, but since it's a Java exception I 
figured it counts as a JRuby problem.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to