jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-3339

java.lang.ArrayIndexOutOfBoundsException in RubyArray.java

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.2
  • Fix Version/s: JRuby 1.2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    jruby 1.1.7 (ruby 1.8.6 patchlevel 287) (2009-01-28 rev 6586) [i386-java]
    Mac OS X 10.5.5 Intel

Description

This bug surfaces when trying to load a Truetype font with the (100% Ruby) Prawn gem, version 0.4.1. I have been unable to trace the exact event where it happens in the Prawn code, but this is an example:

"prawn.rb"
require 'rubygems'
gem 'prawn', '0.4.1'  
require 'prawn'

Prawn::Document.generate "prawn.pdf" do
  font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"  # This is what generates the error
  text "Hello from JRuby"
end

When run in the latest JRuby build as of today:

~/dev% jruby -v
jruby 1.1.7 (ruby 1.8.6 patchlevel 287) (2009-01-28 rev 6586) [i386-java]

~/dev% jruby -S gem list

*** LOCAL GEMS ***

prawn (0.4.1)
prawn-layout (0.1.0)
rake (0.8.3)
rspec (1.1.12)
sources (0.0.1)

~/dev% jruby prawn.rb
RubyArray.java:752:in `eltInternal': java.lang.ArrayIndexOutOfBoundsException: 259
	from Pack.java:1197:in `encode'
	from Pack.java:1494:in `pack'
	from RubyArray.java:3235:in `pack'
...

The code works fine in MRI. Problem is also present in JRuby 1.1.6.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    jruby3339.patch
    31/Jan/09 11:47 AM
    4 kB
    Joseph LaFata

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Charles Oliver Nutter added a comment - 28/Jan/09 2:44 PM

Confirmed on trunk. Here's a trunk trace:

RubyArray.java:752:in `eltInternal': java.lang.ArrayIndexOutOfBoundsException: 259
	from Pack.java:1197:in `encode'
	from Pack.java:1494:in `pack'
	from RubyArray.java:3235:in `pack'
Show
Charles Oliver Nutter added a comment - 28/Jan/09 2:44 PM Confirmed on trunk. Here's a trunk trace:
RubyArray.java:752:in `eltInternal': java.lang.ArrayIndexOutOfBoundsException: 259
	from Pack.java:1197:in `encode'
	from Pack.java:1494:in `pack'
	from RubyArray.java:3235:in `pack'
Hide
Permalink
Charles Oliver Nutter added a comment - 28/Jan/09 2:54 PM - edited

Reduced case:

fmt = "nnnC*"
ary = [0, 262, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 6, 7, 0, 0, 0, 0, 0, 8, 9, 0, 10, 0, 0,
11, 0, 0, 12, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 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jan/09 7:17 PM

You've already got the case reduced well enough ...

but here's some simple steps to reproduce using trunk prawn:

jruby -S gem install test-spec pdf-reader mocha
git clone git://github.com/sandal/prawn.git
cd prawn
git submodule init
git submodule update
jruby -S spec spec/font_spec.rb
Show
Stephen Bannasch added a comment - 30/Jan/09 7:17 PM You've already got the case reduced well enough ... but here's some simple steps to reproduce using trunk prawn:
jruby -S gem install test-spec pdf-reader mocha
git clone git://github.com/sandal/prawn.git
cd prawn
git submodule init
git submodule update
jruby -S spec spec/font_spec.rb
Hide
Permalink
Joseph LaFata added a comment - 31/Jan/09 11:47 AM

Here I come to save the day! That's how you know mighty mouse is on his way!

Anyway, the patch should fix this bug, Charles's test case is correct. I added another test case to the pack/unpack test. I also had a few Digest spec fixes in my working copy, so they're in there too.

Enjoy

If this doesn't work let me know...

Show
Joseph LaFata added a comment - 31/Jan/09 11:47 AM Here I come to save the day! That's how you know mighty mouse is on his way! Anyway, the patch should fix this bug, Charles's test case is correct. I added another test case to the pack/unpack test. I also had a few Digest spec fixes in my working copy, so they're in there too. Enjoy If this doesn't work let me know...
Hide
Permalink
Charles Oliver Nutter added a comment - 31/Jan/09 12:27 PM

Resolved in r8958 by Joseph's fixes. Thanks!

Show
Charles Oliver Nutter added a comment - 31/Jan/09 12:27 PM Resolved in r8958 by Joseph's fixes. Thanks!
Hide
Permalink
Hoa Nguyen added a comment - 30/Mar/09 2:53 PM

sorry but i am using jruby v1.2.0 r9419 and i am still getting this problem. the loading of the font will throw me this exception. it cant be because im using it under glassfish, can it?

[#|2009-03-30T14:42:00.389-0500|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=19;_ThreadName=httpSSLWorkerThread-8181-1;_RequestID=cd3777c4-658e-4d59-8692-0028e4224441;|WebModule[/]Exception caught
java.lang.ArrayIndexOutOfBoundsException: 259
at org.jruby.RubyArray.eltInternal(RubyArray.java:758)
at org.jruby.util.Pack.encode(Pack.java:1141)
at org.jruby.util.Pack.pack(Pack.java:1435)
at org.jruby.RubyArray.pack(RubyArray.java:3277)
at org.jruby.RubyArray$i_method_1_0$RUBYINVOKER$pack.call(org/jruby/RubyArray$i_method_1_0$RUBYINVOKER$pack.gen)
...

Show
Hoa Nguyen added a comment - 30/Mar/09 2:53 PM sorry but i am using jruby v1.2.0 r9419 and i am still getting this problem. the loading of the font will throw me this exception. it cant be because im using it under glassfish, can it? [#|2009-03-30T14:42:00.389-0500|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=19;_ThreadName=httpSSLWorkerThread-8181-1;_RequestID=cd3777c4-658e-4d59-8692-0028e4224441;|WebModule[/]Exception caught java.lang.ArrayIndexOutOfBoundsException: 259 at org.jruby.RubyArray.eltInternal(RubyArray.java:758) at org.jruby.util.Pack.encode(Pack.java:1141) at org.jruby.util.Pack.pack(Pack.java:1435) at org.jruby.RubyArray.pack(RubyArray.java:3277) at org.jruby.RubyArray$i_method_1_0$RUBYINVOKER$pack.call(org/jruby/RubyArray$i_method_1_0$RUBYINVOKER$pack.gen) ...
Hide
Permalink
Martijn Storck added a comment - 15/Apr/09 12:20 PM

Hoa, if you're using warbler this is probably because your .war file includes an older version of the jruby-complete jar. Try replacing the jar in JRUBY_HOME/lib/ruby/gems/1.8/gems/warbler-0.9.12/lib, clear the tmp/war directory of your app and re-warble. That should do the trick.

Show
Martijn Storck added a comment - 15/Apr/09 12:20 PM Hoa, if you're using warbler this is probably because your .war file includes an older version of the jruby-complete jar. Try replacing the jar in JRUBY_HOME/lib/ruby/gems/1.8/gems/warbler-0.9.12/lib, clear the tmp/war directory of your app and re-warble. That should do the trick.
Hide
Permalink
Martijn Storck added a comment - 15/Apr/09 12:21 PM

To clarify: It's working for me now, so this bug is clearly fixed.

Show
Martijn Storck added a comment - 15/Apr/09 12:21 PM To clarify: It's working for me now, so this bug is clearly fixed.
Hide
Permalink
Charles Oliver Nutter added a comment - 16/Apr/09 2:35 AM

Hoa: try Martjin's suggestion...and we'll have a new Warbler release soon that includes updated JRuby.

Show
Charles Oliver Nutter added a comment - 16/Apr/09 2:35 AM Hoa: try Martjin's suggestion...and we'll have a new Warbler release soon that includes updated JRuby.

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Martijn Storck
Vote (0)
Watch (2)

Dates

  • Created:
    28/Jan/09 11:59 AM
    Updated:
    16/Apr/09 2:35 AM
    Resolved:
    31/Jan/09 12:27 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.