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

JRuby 9.3 singleton_class bug #6896

Closed
JacobEvelyn opened this issue Oct 15, 2021 · 2 comments · Fixed by #6900
Closed

JRuby 9.3 singleton_class bug #6896

JacobEvelyn opened this issue Oct 15, 2021 · 2 comments · Fixed by #6900
Milestone

Comments

@JacobEvelyn
Copy link

Hi! I believe I've found a bug that's resulting in JRuby tests failing for panorama-ed/memo_wise that were passing with JRuby 9.2 (and which also pass in all MRI versions).

Environment Information

Provide at least:

  • JRuby version (jruby -v): jruby 9.3.1.0
  • Operating system and platform (e.g. uname -a): Ubuntu 20.04.3 LTS (but have also reproduced on macOS 11.6

Expected Behavior

ObjectSpace.each_object(Module).each(&:singleton_class)

should not crash the Ruby interpreter

Actual Behavior

Unhandled Java exception: java.lang.UnsupportedOperationException: An included class is only a wrapper for a module
java.lang.UnsupportedOperationException: An included class is only a wrapper for a module
            setMetaClass at org/jruby/PrependedModule.java:119
           makeMetaClass at org/jruby/RubyBasicObject.java:548
        toSingletonClass at org/jruby/RubyClass.java:475
        toSingletonClass at org/jruby/MetaClass.java:112
       getSingletonClass at org/jruby/RubyBasicObject.java:532
         singleton_class at org/jruby/RubyKernel.java:1981
                    call at org/jruby/RubyKernel$INVOKER$s$0$0$singleton_class.gen:-1
            cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:351
                    call at org/jruby/runtime/callsite/CachingCallSite.java:144
           yieldSpecific at org/jruby/RubySymbol.java:1467
                 doYield at org/jruby/RubySymbol.java:1460
                   yield at org/jruby/runtime/BlockBody.java:116
             yieldValues at org/jruby/runtime/Block.java:234
                    call at org/jruby/RubyEnumerator.java:391
                    call at org/jruby/runtime/BlockCallback.java:58
                 doYield at org/jruby/runtime/CallBlock.java:91
                   yield at org/jruby/runtime/BlockBody.java:108
                   yield at org/jruby/runtime/Block.java:188
     each_objectInternal at org/jruby/RubyObjectSpace.java:157
             each_object at org/jruby/RubyObjectSpace.java:189
                    call at org/jruby/RubyObjectSpace$INVOKER$s$0$1$each_object.gen:-1
  finvokeWithRefinements at org/jruby/RubyClass.java:510
                 finvoke at org/jruby/RubyClass.java:498
                  invoke at org/jruby/runtime/Helpers.java:645
              callMethod at org/jruby/RubyBasicObject.java:387
                __each__ at org/jruby/RubyEnumerator.java:387
                    each at org/jruby/RubyEnumerator.java:383
                    call at org/jruby/RubyEnumerator$INVOKER$i$each.gen:-1
            cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:362
                    call at org/jruby/runtime/callsite/CachingCallSite.java:154
       invokeOther1:each at path/to/jruby-test.rb:1
             RUBY$script at path/to/jruby-test.rb:1
                     run at path/to/jruby-test.rb:-1
     invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                    load at org/jruby/ir/Compiler.java:114
               runScript at org/jruby/Ruby.java:1257
             runNormally at org/jruby/Ruby.java:1176
             runNormally at org/jruby/Ruby.java:1158
             runNormally at org/jruby/Ruby.java:1194
             runFromMain at org/jruby/Ruby.java:977
           doRunFromMain at org/jruby/Main.java:405
             internalRun at org/jruby/Main.java:289
                     run at org/jruby/Main.java:234
                    main at org/jruby/Main.java:206
JacobEvelyn added a commit to panorama-ed/memo_wise that referenced this issue Oct 15, 2021
Some tests crash the JRuby interpreter due to this
JRuby bug: jruby/jruby#6896

This commit temporarily disables those tests so our
CI builds can pass. Once JRuby fixes the bug we will
remove these workarounds.
@enebo enebo added this to the JRuby 9.3.2.0 milestone Oct 15, 2021
@headius
Copy link
Member

headius commented Oct 21, 2021

I believe this indicates that we are walking IncludedModuleWrapper instances when walking all modules during each_object. Investigating.

headius added a commit to headius/jruby that referenced this issue Oct 21, 2021
@headius
Copy link
Member

headius commented Oct 21, 2021

I pushed #6900 to fix this by avoiding prepended module wrappers in the same way we avoid included module wrappers.

I did not see any specs for this particular behavior, but I'm also not sure exactly what to test here.

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

Successfully merging a pull request may close this issue.

3 participants