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

Concurrency issue when loading TZInfo timezone data using const_get #3968

Closed
ckpeter opened this issue Jun 14, 2016 · 1 comment
Closed

Concurrency issue when loading TZInfo timezone data using const_get #3968

ckpeter opened this issue Jun 14, 2016 · 1 comment

Comments

@ckpeter
Copy link

ckpeter commented Jun 14, 2016

Environment

jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) Client VM 25.92-b14 on 1.8.0_92-b14 +jit [mswin32-x86]

tzinfo version 1.2.2

Expected Behavior

When running this script:

require 'tzinfo'
require 'tzinfo/data'

puts JRUBY_VERSION

threads = [1,1,1,1].map do
  Thread.new do
    begin
      tz = TZInfo::Timezone
      tz.data_source.load_timezone_info('America/New_York')  
    rescue Exception => e
      puts e.inspect
    end
  end
end

threads.each { |t| t.join }

puts 'done'

JRuby 1.7.11 outputs:

1.7.11
done

Actual Behavior

JRuby 9.1.2 seems to have issue with const_get in a multi-threaded context:

9.1.2.0
#<TZInfo::InvalidTimezoneIdentifier: uninitialized constant TZInfo::Data::Definitions>
#<TZInfo::InvalidTimezoneIdentifier: uninitialized constant TZInfo::Data::Definitions>
#<TZInfo::InvalidTimezoneIdentifier: uninitialized constant TZInfo::Data::Definitions>
done

Relevant code in tzinfo:

https://github.com/tzinfo/tzinfo/blob/master/lib/tzinfo/ruby_data_source.rb

Which uses const_get to load data, and which raises above exception when running in a multi-threaded context in JRuby 9.1.2.

@kares
Copy link
Member

kares commented Jan 17, 2017

seems to be running fine in 9.1.6 / 9.1.7 ... so this is likely resolved since 9.1.2 :

kares@sputnik:~/workspace/oss/jruby$ ruby tzinfo_test.rb
9.1.6.0
done

@kares kares closed this as completed Jan 17, 2017
@kares kares added this to the Invalid or Duplicate milestone Jan 17, 2017
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

2 participants