Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Strange FloatDomainError #1722

Closed
kwando opened this Issue · 7 comments

5 participants

@kwando

Hi, I have recently gotten a number of FloatDomainErrors from jruby when using the number_to_human_size helper method in rails.

  "message": "-Infinity",
  "backtrace": [
    "org/jruby/RubyFloat.java:822:in `floor'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_to_rounded_converter.rb:66:in `digit_count'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_to_rounded_converter.rb:56:in `digits_and_rounded_number'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_to_rounded_converter.rb:25:in `convert'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_converter.rb:132:in `execute'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_converter.rb:118:in `convert'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_to_human_size_converter.rb:21:in `convert'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_converter.rb:132:in `execute'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper/number_converter.rb:118:in `convert'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/number_helper.rb:242:in `number_to_human_size'",
    "org/jruby/RubyKernel.java:1963:in `public_send'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/helpers/number_helper.rb:390:in `delegate_number_helper_method'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/helpers/number_helper.rb:414:in `wrap_with_output_safety_handling'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/helpers/number_helper.rb:389:in `delegate_number_helper_method'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/helpers/number_helper.rb:278:in `number_to_human_size'",
    "/home/torquebox/abis/app/views/form_entry_attachments/index.html.erb:13:in `_app_views_form_entry_attachments_index_html_erb___581381528_23978'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/mongoid-4.0.0.beta1/lib/mongoid/contextual/memory.rb:104:in `each'",
    "org/jruby/RubyArray.java:1613:in `each'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/mongoid-4.0.0.beta1/lib/mongoid/contextual/memory.rb:103:in `each'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/mongoid-4.0.0.beta1/lib/mongoid/contextual.rb:20:in `each'",
    "/home/torquebox/abis/app/views/form_entry_attachments/index.html.erb:7:in `_app_views_form_entry_attachments_index_html_erb___581381528_23978'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/template.rb:145:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications.rb:161:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/template.rb:339:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/template.rb:143:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/template_renderer.rb:55:in `render_template'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications/instrumenter.rb:19:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/template_renderer.rb:54:in `render_template'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/template_renderer.rb:53:in `render_template'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/template_renderer.rb:17:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/renderer.rb:42:in `render_template'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/renderer/renderer.rb:23:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/rendering.rb:99:in `_render_template'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/streaming.rb:217:in `_render_template'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/rendering.rb:82:in `render_to_body'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/rendering.rb:32:in `render_to_body'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/renderers.rb:32:in `render_to_body'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/abstract_controller/rendering.rb:25:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/rendering.rb:16:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:41:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/core_ext/benchmark.rb:12:in `ms'",
    "/opt/torquebox/current/jruby/lib/ruby/2.0/benchmark.rb:296:in `realtime'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/core_ext/benchmark.rb:12:in `ms'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:41:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:40:in `render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/implicit_render.rb:10:in `default_render'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/implicit_render.rb:5:in `send_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/abstract_controller/base.rb:189:in `process_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/rendering.rb:10:in `process_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/abstract_controller/callbacks.rb:20:in `process_action'",
    "org/jruby/RubyProc.java:271:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/callbacks.rb:113:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/callbacks.rb:166:in `halting'",
    "org/jruby/RubyProc.java:271:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/callbacks.rb:166:in `halting'",
    "org/jruby/RubyProc.java:271:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/callbacks.rb:229:in `halting'",
    "org/jruby/RubyProc.java:271:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/callbacks.rb:166:in `halting'",
    "org/jruby/RubyProc.java:271:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/callbacks.rb:86:in `run_callbacks'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/abstract_controller/callbacks.rb:19:in `process_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/rescue.rb:29:in `process_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:31:in `process_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications/instrumenter.rb:19:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/notifications.rb:159:in `instrument'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:30:in `process_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/abstract_controller/base.rb:136:in `process'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionview-4.1.0/lib/action_view/rendering.rb:30:in `process'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal.rb:195:in `dispatch'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_controller/metal.rb:231:in `action'",
    "org/jruby/RubyProc.java:271:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:80:in `dispatch'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:48:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/journey/router.rb:71:in `call'",
    "org/jruby/RubyArray.java:1613:in `each'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/journey/router.rb:59:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:676:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/params_parser.rb:27:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/flash.rb:254:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/cookies.rb:560:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/callbacks.rb:29:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/callbacks.rb:82:in `run_callbacks'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/callbacks.rb:27:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/railties-4.1.0/lib/rails/rack/logger.rb:38:in `call_app'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/railties-4.1.0/lib/rails/rack/logger.rb:20:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/tagged_logging.rb:68:in `tagged'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/tagged_logging.rb:26:in `tagged'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/activesupport-4.1.0/lib/active_support/tagged_logging.rb:68:in `tagged'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/railties-4.1.0/lib/rails/rack/logger.rb:20:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/request_id.rb:21:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/actionpack-4.1.0/lib/action_dispatch/middleware/static.rb:64:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/railties-4.1.0/lib/rails/engine.rb:514:in `call'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/railties-4.1.0/lib/rails/application.rb:144:in `call'",
    "org/jruby/RubyKernel.java:1963:in `public_send'",
    "/home/torquebox/abis/vendor/bundle/jruby/1.9/gems/railties-4.1.0/lib/rails/railtie.rb:194:in `method_missing'"
  ],
@enebo
Owner

If you could capture and log the value(s) which cause that error it would be great.

@kwando

Here is a barebones rails app demonstrating the issue:
https://github.com/kwando/float_error

http://localhost:3000/1023 <-- works
http://localhost:3000/1024 <-- does not work

the uri path is converted to a integer and number_to_human_size is called with that value.

@coderdave

Getting that error here too... is there a workaround?

@enebo
Owner

Could someone put a puts in activesupport in digit_count where it is happening and print the value. The Rails app is better than nothing (and we do appreciate it) but I was hoping this would get reduced a little more than that.

@sluukkonen

I reduced it to (using 1.7.12)

BigDecimal(100) * Rational(1, 100) # => 0.0 (as a BigDecimal)

Going to take a look at BigDecimal code tomorrow, if anyone else hasn't already done so.

@atambo
Collaborator

This sounds related to #1695

@enebo enebo added this to the JRuby 1.7.13 milestone
@enebo
Owner

Thanks for the teamwork. #1695 does appear to be the base of this issue and the PR attached fixes it. Resolving.

@enebo enebo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.