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

java.lang.NoSuchMethodError: rubyobj.Grape.Util.InheritableValues.callMethod when running with -Xreify.classes=true #4444

Closed
ivoanjo opened this Issue Jan 17, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@ivoanjo
Copy link
Contributor

ivoanjo commented Jan 17, 2017

Environment

Running jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.111-b14 on 1.8.0_111-b14 +jit [linux-x86_64] on Linux maruchan 4.9.0-11-generic #12-Ubuntu SMP Mon Dec 12 16:18:23 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux.

Expected Behavior

Example testcase:

require 'grape'

class Foo < Grape::API
  post { }
end

(Attached version includes Gemfile and Gemfile.lock: testcase.zip)

When running under JRuby normally, this code has no problems.

Actual Behavior

When running this code with jruby -Xreify.classes=true test.rb it results in the following exception:

Unhandled Java exception: java.lang.NoSuchMethodError: rubyobj.Grape.Util.InheritableValues.callMethod(Ljava/lang/String;Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;
java.lang.NoSuchMethodError: rubyobj.Grape.Util.InheritableValues.callMethod(Ljava/lang/String;Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;
      initialize_copy at rubyobj/Grape/Util/InheritableValues:-1
      initialize_copy at org/jruby/RubyKernel.java:1836
                 call at org/jruby/RubyKernel$INVOKER$s$1$0$initialize_copy.gen:-1
                 call at org/jruby/internal/runtime/methods/JavaMethod.java:738
        instanceSuper at org/jruby/ir/runtime/IRRuntimeHelpers.java:990
            interpret at org/jruby/ir/instructions/InstanceSuperInstr.java:69
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:356
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
            interpret at org/jruby/ir/interpreter/InterpreterEngine.java:84
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:179
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:165
                 call at org/jruby/internal/runtime/methods/DynamicMethod.java:200
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:338
                 call at org/jruby/runtime/callsite/CachingCallSite.java:163
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:315
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
            interpret at org/jruby/ir/interpreter/InterpreterEngine.java:84
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:179
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:165
                 call at org/jruby/internal/runtime/methods/DynamicMethod.java:200
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:338
                 call at org/jruby/runtime/callsite/CachingCallSite.java:163
             initCopy at org/jruby/RubyBasicObject.java:911
              rbClone at org/jruby/RubyBasicObject.java:963
              rbClone at org/jruby/RubyKernel.java:1881
                 call at org/jruby/RubyKernel$INVOKER$s$0$0$rbClone.gen:-1
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:318
                 call at org/jruby/runtime/callsite/CachingCallSite.java:131
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:340
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
      INTERPRET_BLOCK at org/jruby/ir/interpreter/Interpreter.java:132
      commonYieldPath at org/jruby/runtime/MixedModeIRBlockBody.java:148
              doYield at org/jruby/runtime/IRBlockBody.java:182
                yield at org/jruby/runtime/BlockBody.java:111
                yield at org/jruby/runtime/Block.java:167
                  tap at org/jruby/RubyKernel.java:1747
                 call at org/jruby/RubyKernel$INVOKER$s$0$0$tap.gen:-1
                 call at org/jruby/internal/runtime/methods/JavaMethod.java:497
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:298
            callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
                 call at org/jruby/runtime/callsite/CachingCallSite.java:83
            interpret at org/jruby/ir/instructions/CallBase.java:428
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:356
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
            interpret at org/jruby/ir/interpreter/InterpreterEngine.java:78
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:144
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:130
                 call at org/jruby/internal/runtime/methods/DynamicMethod.java:192
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:318
                 call at org/jruby/runtime/callsite/CachingCallSite.java:131
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:340
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:109
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:95
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:298
            callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
                 call at org/jruby/runtime/callsite/CachingCallSite.java:83
          newInstance at org/jruby/RubyClass.java:1022
                 call at org/jruby/RubyClass$INVOKER$i$newInstance.gen:-1
        instanceSuper at org/jruby/ir/runtime/IRRuntimeHelpers.java:990
            interpret at org/jruby/ir/instructions/InstanceSuperInstr.java:69
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:356
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:109
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:95
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:298
            callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
                 call at org/jruby/runtime/callsite/CachingCallSite.java:83
            interpret at org/jruby/ir/instructions/CallBase.java:428
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:356
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:109
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:95
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:298
            callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
                 call at org/jruby/runtime/callsite/CachingCallSite.java:83
            interpret at org/jruby/ir/instructions/CallBase.java:428
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:356
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:109
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:95
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:298
            callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
                 call at org/jruby/runtime/callsite/CachingCallSite.java:83
            interpret at org/jruby/ir/instructions/CallBase.java:428
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:356
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
      INTERPRET_BLOCK at org/jruby/ir/interpreter/Interpreter.java:132
      commonYieldPath at org/jruby/runtime/MixedModeIRBlockBody.java:148
                 call at org/jruby/runtime/IRBlockBody.java:69
                 call at org/jruby/runtime/Block.java:126
                 call at org/jruby/RubyProc.java:289
                 call at org/jruby/internal/runtime/methods/ProcMethod.java:63
                 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
    invokeOther3:post at test.rb:4
          <class:Foo> at test.rb:4
                 call at org/jruby/internal/runtime/methods/CompiledIRMethod.java:77
                 call at org/jruby/internal/runtime/methods/CompiledIRMethod.java:87
     invokeModuleBody at org/jruby/ir/runtime/IRRuntimeHelpers.java:1422
               <main> at test.rb:3
  invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                 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

This comment has been minimized.

Copy link
Member

headius commented Jan 17, 2017

I'm guessing this is a recent attempt to upgrade? The reify.classes feature has always been experimental. In particular, it has never worked properly with reify.variables which has been ON by default since JRuby 9.1. There's a separate issue tracking the breakage in reify.variables. It's most likely that they'll become the same setting internally in the future and we'll always reify classes, but that decision has not been made (since it will require generating many more JVM classes than we do today).

Can you give me some background about how you're using this feature? Are you doing it solely to be able to heap analyze a Ruby app?

@ivoanjo

This comment has been minimized.

Copy link
Contributor

ivoanjo commented Jan 17, 2017

I had left this setting on my .jrubyrc as I had been debugging some memory issues, and thought I'd leave it always on for my development machine.

If the breakage is known/being tracked elsewhere, feel free to close, as I'm definitely not using it in production (although as it is THE tool for analyzing heap dumps it definitely would be beyond awesome to be on by default, or at least be fully supported).

@headius

This comment has been minimized.

Copy link
Member

headius commented Jan 19, 2017

@ivoanjo Ok, I'll dig up the other issue and link it here. For now just omit that flag. We will try to get it working again for 9.1.8.0 or 9.2.

@headius headius closed this Jan 19, 2017

@headius

This comment has been minimized.

Copy link
Member

headius commented Jan 19, 2017

Link to #3793.

@headius headius added this to the Invalid or Duplicate milestone Jan 19, 2017

ivoanjo pushed a commit to Talkdesk/jruby that referenced this issue Jun 1, 2017

Ivo Anjo
Fix missing callMethod override
Although not used by default, the Reificator class at
https://github.com/jruby/jruby/blob/9.1.10.0/core/src/main/java/org/jruby/RubyClass.java#L1583
checks which version of callMethod it should use, and needs all three
versions: no argument, one argument, and more than one argument.

One of these overrides did not exist, and thus would result on a

```
java.lang.NoSuchMethodError: rubyobj.BrokenReify.callMethod(
Ljava/lang/String;Lorg/jruby/runtime/builtin/IRubyObject;)
Lorg/jruby/runtime/builtin/IRubyObject;
```

when running an example with -Xreify.classes=true

```ruby
class BrokenReify
  def initialize_copy(other)
    super
  end
end

puts BrokenReify.new.clone
```

With this fix, the above example starts instead giving a
java.lang.StackOverflowError due to another bug/bad interaction of the
reify.classes option, which I'll report separately.

Issue jruby#4444
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment