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

Time.now sometimes attempts to call libc gettimeofday on Windows #4565

Closed
aschmied opened this issue Apr 19, 2017 · 1 comment
Closed

Time.now sometimes attempts to call libc gettimeofday on Windows #4565

aschmied opened this issue Apr 19, 2017 · 1 comment

Comments

@aschmied
Copy link

Environment

> jruby -v
jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.66-b18 on 1.8.0_66-b18 +jit [mswin32-x86_64]

JRUBY_OPTS=-J-Xms512m -J-Xmx1024m -J-XX:+HeapDumpOnOutOfMemoryError -J-XX:HeapDumpPath=C:/Users/AnthonySchmieder/Desktop/tmp/jruby_hprofs/jruby_jvm_heap_dump.hprof -Xnative.verbose=true

Rails 4.2.7.1
RSpec 3.5.0
Windows 10

Expected Behavior

Time.now returns the time

Actual Behavior

This looks related to #4501. We have an RSpec test for a class that calls Rails.cache.fetch. Sometimes that call attmpts to call the libc gettimeofday method and throws a NotImplementedError. I have not been able to determine the factors that make the call fail.

Here is the call stack:

     NotImplementedError:
       gettimeofday unsupported or native support failed to load; see http://wiki.jruby.org/Native-Libraries
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:612:in `initialize'
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:390:in `block in write'
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:547:in `block in instrument'
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166:in `instrument'
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:547:in `instrument'
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:389:in `write'
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:588:in `save_block_result_to_cache'
     # ./.gems/gems/activesupport-4.2.7.1/lib/active_support/cache.rb:299:in `fetch'
     # ./app/models/config/option.rb:223:in `index'
     ... more from our application code

The failing line in cache.rb::initialize is:

@created_at = Time.now.to_f

This fails deterministically (always on the same spec), but does not fail for all calls to Rails.cache.fetch. Also a call to Time.now placed immediately before the call to Rails.cache.fetch always works. Also there are no errors loading a POSIX implementation:

Successfully loaded native POSIX impl.

A workaround is to set native.enabled=false in my .jrubyrc.

@headius
Copy link
Member

headius commented Apr 19, 2017

I think the best answer for us here, until we have gettimeofday modified to do the "right thing" on Windows, would be to make the Windows version just provide System.currentTimeMillis as the fallback code does.

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