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

Rails new fails on master 9e6c2be in Thor #2198

Closed
mjc opened this issue Nov 14, 2014 · 8 comments
Closed

Rails new fails on master 9e6c2be in Thor #2198

mjc opened this issue Nov 14, 2014 · 8 comments

Comments

@mjc
Copy link
Contributor

mjc commented Nov 14, 2014

$ rails new blankapp
NoMethodError: protected method `destination=' called for #<Thor::Actions::EmptyDirectory:0x6d842877>
       initialize at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:36
  empty_directory at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:14
      create_root at /Users/mjc/.gem/jruby/2.2.0/gems/railties-4.1.7/lib/rails/generators/app_base.rb:139
      create_root at (eval):1
              run at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27
   invoke_command at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126
       invoke_all at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133
             each at org/jruby/RubyHash.java:1355
              map at org/jruby/RubyEnumerable.java:745
       invoke_all at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133
         dispatch at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/group.rb:232
            start at /Users/mjc/.gem/jruby/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440
           (root) at /Users/mjc/.gem/jruby/2.2.0/gems/railties-4.1.7/lib/rails/commands/application.rb:17
          require at org/jruby/RubyKernel.java:954
           (root) at /Users/mjc/.rubies/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
          require at /Users/mjc/.rubies/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:69
          require at org/jruby/RubyKernel.java:954
           (root) at /Users/mjc/.gem/jruby/2.2.0/gems/railties-4.1.7/lib/rails/cli.rb:14
           (root) at /Users/mjc/.rubies/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
             load at org/jruby/RubyKernel.java:969
       __script__ at /Users/mjc/.gem/jruby/2.2.0/bin/rails:23
@mjc mjc changed the title Rails new fails on master 252bd4e in Thor Rails new fails on master 9e6c2be in Thor Nov 14, 2014
@subbuss
Copy link
Contributor

subbuss commented Nov 14, 2014

jruby -X-C -S rails new blankapp works in f1eca7a but fails in 5f717bd ... those are somewhat arbitrary commits in the end-August to late-October timeframe.

Maybe worth bisecting if simple to do. Otherwise, will take a look over the weekend.

@subbuss
Copy link
Contributor

subbuss commented Nov 14, 2014

Started bisecting ... good in c7a3739 .. bad in 23a3d2f.

@subbuss
Copy link
Contributor

subbuss commented Nov 14, 2014

Finished and it fingered 0630462 .. but turning off the pass in master doesn't fix it. Will investigate tomorrow. It will also help find a regression spec.

@subbuss
Copy link
Contributor

subbuss commented Nov 15, 2014

Looked into this a little bit. If I disable frame-removal optimization in AddCallProtocolInstructions.java (replace "return requiresFrame" with "return true" .. line 150 of that file), this works again.

The reason I came to this is by finding that the 'self' used to verify access protection is not the same as the receiver passed into the call. This is because invoke methods in RubyClass.java use "IRubyObject caller = context.getFrameSelf();" to test access protections. So, if a frame has been eliminated for these scopes, it uses the wrong object to test access protection!

Pinging @headius and @enebo to see what the right fix is for this. But, I am also curious why RubyClass.java:invoke is using frame-self rather than the 'self' that has been passed in. If there is a reason for doing that, 'doesItRequireFrame' method requires an update to not eliminate frames that have these 'invoke' calls.

We also need a regression spec for this.

@subbuss
Copy link
Contributor

subbuss commented Nov 15, 2014

Ah never mind .. I get it .. access protection has to use the self of the caller's frame. So, there is an information gap here in the doesItRequireFrame method.

@subbuss
Copy link
Contributor

subbuss commented Nov 15, 2014

Looking around, looks like attr-assign instructions are the only users of Helpers.invoke(..) .. so, the easy fix was to add a computeScopeFlags() to that and fix it. However, a better fix would be to explicitly pass in the caller-self into Helpers.invoke(..) since that is available rather than try to get it off the frame stack.

Longer term, we should be able to make access-protection checks, method lookups, etc. as separate instructions which could then be optimized away in certain scenarios.

@subbuss
Copy link
Contributor

subbuss commented Nov 15, 2014

While the regression spec is passing via jruby -S rspec, in actuality, default jruby run fails the test. But, jruby -X-C passes it. See below. So, the attr_reader access check is not working in JIT mode?

[subbu@earth lib] jruby /tmp/boo.rb
[nil, 10]
[subbu@earth lib] jruby -X-C /tmp/boo.rb
["NoMethodError", 10]
[subbu@earth lib] cat /tmp/boo.rb
class C
def update(v); self.v = v; end

protected
attr_accessor :v
end

a = []
begin
a << C.new.v
rescue => e
a << e.class.name
end

begin
a << C.new.update(10)
rescue => e
a << e.class.name
end

p a

@subbuss subbuss reopened this Nov 15, 2014
@subbuss
Copy link
Contributor

subbuss commented Nov 15, 2014

Opening a new issue for this.

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