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

LocalJumpError: yield called out of block in JRuby 9.0.0.0.pre2 #3009

Closed
judofyr opened this issue May 31, 2015 · 9 comments
Closed

LocalJumpError: yield called out of block in JRuby 9.0.0.0.pre2 #3009

judofyr opened this issue May 31, 2015 · 9 comments

Comments

@judofyr
Copy link

judofyr commented May 31, 2015

We got this bug report in Tilt (https://gith/ub.com/rtomayko/tilt/issues/235#issuecomment-107020136) by @TobiG77. I think this is a bug in JRuby?

I can reliably reproduce this with jruby-9.0.0.0.pre2 with aws-sdk v2.0.47.

MRI (2.2.2) and jruby-1.7.19 both work fine.

irb(main):035:0> object = s3.bucket(ENV['AWS_BUCKET']).object('hello-world/hello-world.tar.gz')
=> #<Aws::S3::Object bucket_name="xyz", key="hello-world/hello-world.tar.gz">
irb(main):036:0> object.upload_file('./hello-world.tar.gz')
LocalJumpError: yield called out of block
        from org/jruby/RubyProc.java:303:in `call'
        from org/jruby/RubyYielder.java:101:in `yield'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/model/shapes.rb:252:in `block in members'
        from org/jruby/RubyArray.java:2308:in `map'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/model/shapes.rb:251:in `block in members'
        from org/jruby/RubyProc.java:303:in `call'
        from org/jruby/RubyGenerator.java:102:in `each'
        from org/jruby/RubyEnumerator.java:300:in `each'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/model/shapes.rb:282:in `index_members_by_location_name'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/model/shapes.rb:275:in `member_by_location_name'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/plugins/endpoint.rb:54:in `block in apply_path_params'
        from org/jruby/RubyString.java:2409:in `gsub'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/plugins/endpoint.rb:47:in `apply_path_params'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/plugins/endpoint.rb:38:in `build_endpoint'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/plugins/endpoint.rb:30:in `call'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/plugins/param_validation.rb:22:in `call'
... 1 levels...
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:18:in `call'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/plugins/param_conversion.rb:22:in `call'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/aws-sdk-core/plugins/response_paging.rb:10:in `call'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/plugins/response_target.rb:18:in `call'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/request.rb:70:in `send_request'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-core-2.0.47/lib/seahorse/client/base.rb:216:in `block in create_multipart_upload'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-resources-2.0.47/lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb:42:in `initiate_upload'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-resources-2.0.47/lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb:33:in `upload'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-resources-2.0.47/lib/aws-sdk-resources/services/s3/file_uploader.rb:32:in `upload'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/aws-sdk-resources-2.0.47/lib/aws-sdk-resources/services/s3/object.rb:102:in `upload_file'
        from (irb):36:in `<eval>'
        from org/jruby/RubyKernel.java:1005:in `eval'
        from org/jruby/RubyKernel.java:1315:in `loop'
        from org/jruby/RubyKernel.java:1125:in `catch'
        from org/jruby/RubyKernel.java:1125:in `catch'
        from /home/developer/.rbenv/versions/jruby-9.0.0.0.pre2/bin/irb:13:in `<top>'irb(main):037:0> 
irb(main):038:0* 
@headius
Copy link
Member

headius commented Jun 1, 2015

Looking into this.

@headius headius added this to the JRuby 9.0.0.0 milestone Jun 1, 2015
@TobiG77
Copy link

TobiG77 commented Jun 1, 2015

If it's any help, I've played around with the aws-sdk v2. as per: https://ruby.awsblog.com/post/Tx1K43Z7KXHM5D5/Uploading-Files-to-Amazon-S3

@dblock
Copy link

dblock commented Jun 1, 2015

See https://github.com/LTe/grape-rabl that would/is still failing in this way.

@enebo
Copy link
Member

enebo commented Jun 2, 2015

@dblock It is possible 1.7 and 9k have the same problem (localjumperror has been due to lots of issues) but could you open your grape-rabl issue as a new one? Even if they are the same underlying problem the impls are so different wrt to non-local flow control and they will end up as completely different fixes (plus this also works a little nicer with github issues...yeah bonus!).

@headius
Copy link
Member

headius commented Jun 2, 2015

Reproduction:

def members
  Enumerator.new do |y|
    [1, 2, 3, 4].map do |n|
      y.yield([n, n], n)
    end
  end
end

def index_members_by_location_name
  members.each.with_object({}) do |(name, shape), hash|
    p [name, shape, hash]
  end
end

index_members_by_location_name

@headius
Copy link
Member

headius commented Jun 2, 2015

Ahh I see the problem here.

The code in aws-sdk does enum.each.with_object, which is a little unusual. Our logic for Enumerator#each was not "enumeratorizing" when each is called with no block, so the null block propagated through to the Yielder, and then eventually was invoked. I'm fixing Enumerator#each to enumeratorize properly when no block is passed in, and it appears to fix the problem.

I call this an unusual form because generally if you have an Enumerable object, you'd just call each_with_object rather than each.with_object. The latter case apparently doesn't have much in the way of tests.

@dblock
Copy link

dblock commented Jun 3, 2015

I tried to find a workaround for Rabl, but failed. You can see nesquena/rabl#544 for details.

@headius
Copy link
Member

headius commented Jun 3, 2015

I think I have the fix, after a bit of fiddling around.

@dblock
Copy link

dblock commented Jun 3, 2015

@headius I would love an explanation of what's going on in Rabl with this and possibly a work-around so that works with all existing versions.

headius added a commit to ruby/spec that referenced this issue Jun 5, 2015
kares added a commit that referenced this issue Apr 20, 2017
* Implemented Enumerator#peek_values

* Implemented Enumerator#next_values

* Implemented Enumerator#feed method

* Set feedValue to nil for Enumerator#next_values method as well

* Reduce getRuntime/context.runtime calls for better performance

* Fix the bug with size with each_slice without block

* Return Enumerator self calling #each with no block. Fixes #3009.

+ back-port-fix: make sure feedValue is always initialized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants