Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectSpace.each_object.to_a raises ArrayIndexOutOfBoundsException #4461

Closed
javierhonduco opened this issue Jan 27, 2017 · 4 comments
Closed
Milestone

Comments

@javierhonduco
Copy link
Contributor

javierhonduco commented Jan 27, 2017

Environment

jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 24.65-b04 on 1.7.0_67-b01 +jit [darwin-x86_64]

Darwin MacBook-Air-de-Javier-3.local 16.1.0 Darwin Kernel Version 16.1.0: Wed Oct 19 20:31:56 PDT 2016; root:xnu-3789.21.4~4/RELEASE_X86_64 x86_64

Expected Behavior

~ ruby -e "puts ObjectSpace.each_object.to_a"

Should print all living objects.

Actual Behavior

An ArrayIndexOutOfBounds Exception is raised

~ ruby -e "puts ObjectSpace.each_object.to_a"
Unhandled Java exception: java.lang.ArrayIndexOutOfBoundsException: 0
java.lang.ArrayIndexOutOfBoundsException: 0
  each_objectInternal at org/jruby/RubyObjectSpace.java:152
          each_object at org/jruby/RubyObjectSpace.java:181
                 call at org/jruby/RubyObjectSpace$INVOKER$s$0$1$each_object.gen:-1
              finvoke at org/jruby/RubyClass.java:522
               invoke at org/jruby/runtime/Helpers.java:395
           callMethod at org/jruby/RubyBasicObject.java:385
                 each at org/jruby/RubyEnumerator.java:323
                 call at org/jruby/RubyEnumerator$INVOKER$i$each.gen:-1
              finvoke at org/jruby/RubyClass.java:512
               invoke at org/jruby/runtime/Helpers.java:383
             callEach at org/jruby/RubyEnumerable.java:102
                 to_a at org/jruby/RubyEnumerable.java:459
                 call at org/jruby/RubyEnumerable$INVOKER$s$to_a.gen:-1
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:318
                 call at org/jruby/runtime/callsite/CachingCallSite.java:131
    invokeOther1:to_a at -e:1
               <main> at -e:1
  invokeWithArguments at java/lang/invoke/MethodHandle.java:599
                 load at org/jruby/ir/Compiler.java:111
            runScript at org/jruby/Ruby.java:834
          runNormally at org/jruby/Ruby.java:749
          runNormally at org/jruby/Ruby.java:767
          runFromMain at org/jruby/Ruby.java:580
        doRunFromMain at org/jruby/Main.java:425
          internalRun at org/jruby/Main.java:313
                  run at org/jruby/Main.java:242
                 main at org/jruby/Main.java:204
@javierhonduco javierhonduco changed the title ObjectSpace.each_object raises ArrayIndexOutOfBoundsException ObjectSpace.each_object.to_a raises ArrayIndexOutOfBoundsException Jan 27, 2017
@kirs
Copy link
Contributor

kirs commented Jan 27, 2017

For me it happens just for each_object:

$ jruby --version
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
$ cat obj.rb
ObjectSpace.each_object do |obj|
end
$ jruby --dev obj.rb
Unhandled Java exception: java.lang.ArrayIndexOutOfBoundsException: 0
java.lang.ArrayIndexOutOfBoundsException: 0
       each_objectInternal at org/jruby/RubyObjectSpace.java:152
               each_object at org/jruby/RubyObjectSpace.java:181
                      call at org/jruby/RubyObjectSpace$INVOKER$s$0$1$each_object.gen:-1
                      call at org/jruby/internal/runtime/methods/DynamicMethod.java:196
              cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:328
                 callBlock at org/jruby/runtime/callsite/CachingCallSite.java:141
                      call at org/jruby/runtime/callsite/CachingCallSite.java:145
  invokeOther1:each_object at obj.rb:1
                    <main> at obj.rb:1
       invokeWithArguments at java/lang/invoke/MethodHandle.java:625
                      load at org/jruby/ir/Compiler.java:90
                 runScript at org/jruby/Ruby.java:823
               runNormally at org/jruby/Ruby.java:742
               runNormally at org/jruby/Ruby.java:760
               runFromMain at org/jruby/Ruby.java:573
             doRunFromMain at org/jruby/Main.java:417
               internalRun at org/jruby/Main.java:305
                       run at org/jruby/Main.java:232
                      main at org/jruby/Main.java:204

@headius
Copy link
Member

headius commented Jan 27, 2017

Confirmed. AIOOBE for me both with and without -X+O (which enables full ObjectSpace features).

@javierhonduco
Copy link
Contributor Author

Thanks a lot!! 💞

@kirs
Copy link
Contributor

kirs commented Jan 28, 2017

Thanks for fixing it! Does it make sense to add a regression test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants