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

Indy exception while bundle install'ing a Rails app with -X+C #4140

Closed
headius opened this issue Sep 7, 2016 · 3 comments
Closed

Indy exception while bundle install'ing a Rails app with -X+C #4140

headius opened this issue Sep 7, 2016 · 3 comments

Comments

@headius
Copy link
Member

headius commented Sep 7, 2016

Environment

JRuby pre-9.1.5.0 master on any JVM (I would expect).

Expected Behavior

JRuby should be able to generate and bundle a Rails app with -X+C specified.

Actual Behavior

Instead, it blows up inside bundle install with the following output:

...
         run  bundle install
Fetching gem metadata from https://rubygems.org/Retrying fetcher due to error (2/4): Java::JavaLangInvoke::WrongMethodTypeException expected (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,Block,Block)IRubyObject but found (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,RubyModule,String)IRubyObject
Retrying fetcher due to error (3/4): Java::JavaLangInvoke::WrongMethodTypeException expected (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,Block,Block)IRubyObject but found (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,RubyModule,String)IRubyObject
Retrying fetcher due to error (4/4): Java::JavaLangInvoke::WrongMethodTypeException expected (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,Block,Block)IRubyObject but found (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,RubyModule,String)IRubyObject
--- ERROR REPORT TEMPLATE -------------------------------------------------------
- What did you do?

  I ran the command `/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bundler-1.12.5/exe/bundle install`

- What did you expect to happen?

  I expected Bundler to...

- What happened instead?

  Instead, what actually happened was...


Error details

    Java::JavaLangInvoke::WrongMethodTypeException: expected (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,Block,Block)IRubyObject but found (ThreadContext,StaticScope,IRubyObject,IRubyObject[],Block,RubyModule,String)IRubyObject
      java.lang.invoke.Invokers.newWrongMethodTypeException(Invokers.java:298)
      java.lang.invoke.Invokers.checkExactType(Invokers.java:309)
      org.jruby.internal.runtime.methods.CompiledIRMethod.invokeExact(CompiledIRMethod.java:210)
      org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:88)
      org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:113)
      org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:198)
      org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:205)
      org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:193)
      Users.headius.projects.jruby.lib.ruby.gems.shared.gems.bundler_minus_1_dot_12_dot_5.lib.bundler.endpoint_specification.invokeOther0:build_dependency(/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bundler-1.12.5/lib/bundler/endpoint_specification.rb:15)
      Users.headius.projects.jruby.lib.ruby.gems.shared.gems.bundler_minus_1_dot_12_dot_5.lib.bundler.endpoint_specification.RUBY$block$initialize$0(/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bundler-1.12.5/lib/bundler/endpoint_specification.rb:15)
...

It appears a method is not getting bound using CompiledIRMethod + indy handles properly. The method in question (from bundler's endpoint_specification.rb:15) looks like this...pretty mundane method signature etc:

    def build_dependency(name, *requirements)
      Gem::Dependency.new(name, *requirements)
    rescue ArgumentError => e
      raise unless e.message.include?(ILLFORMED_MESSAGE)
      puts # we shouldn't print the error message on the "fetching info" status line
      raise GemspecError,
        "Unfortunately, the gem #{name} (#{version}) has an invalid " \
        "gemspec.\nPlease ask the gem author to yank the bad version to fix " \
        "this issue. For more information, see http://bit.ly/syck-defaultkey."
    end
@headius
Copy link
Member Author

headius commented Sep 7, 2016

Ok, this appears to be a Graal error. If I run on OpenJDK 7 or 8 it works fine, but on Graal at some point an indy method handle's signature gets mangled to have three "Block" arguments instead of Block, RubyModule, String.

I tracked it down to JVMVisitor.signatureFor, which uses invokebinder to build up a Signature object.

I logged the body name, METHOD_SIGNATURE_BASE, and the insertArgs modified version of it, which looks like this:

EndpointSpecification
(ThreadContext context, StaticScope scope, IRubyObject self, Block blockArg, RubyModule class, String callName)IRubyObject
(ThreadContext context, StaticScope scope, IRubyObject self, IRubyObject[] args, Block blockArg, RubyModule class, String callName)IRubyObject
initialize
(ThreadContext context, StaticScope scope, IRubyObject self, Block blockArg, RubyModule class, String callName)IRubyObject
(ThreadContext context, StaticScope scope, IRubyObject self, IRubyObject[] args, Block blockArg, RubyModule class, String callName)IRubyObject

After running for some amount of time, this starts to output the bad signature:

(ThreadContext context, StaticScope scope, IRubyObject self, Block blockArg, RubyModule class, String callName)IRubyObject
(ThreadContext context, StaticScope scope, IRubyObject self, IRubyObject[] args, Block blockArg, Block class, Block callName)IRubyObject

The only method-type modification that happens inside Signature.insertArgs is MethodType.insertParameterTypes, so it seems like that's busted on Graal 0.15.

@thomaswue Would you prefer I move this to the Graal issue tracker?

@headius headius modified the milestones: Non-Release, JRuby 9.1.6.0 Sep 7, 2016
@headius headius removed the jit label Sep 7, 2016
@thomaswue
Copy link
Contributor

Yes, please create an issue in the Graal tracker.

@headius
Copy link
Member Author

headius commented Sep 13, 2016

@thomaswue Done! https://github.com/graalvm/graal-core/issues/207

Closing this since it's a Graal issue.

@headius headius closed this as completed Sep 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants