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

Remove thread-unsafe runtime requires #43

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Jun 28, 2023

  1. Replace thread-unsafe runtime requires with vanilla autoload

    Dynamically requiring implementations at runtime in this way is not safe
    in a multithreaded program, even in MRI with the GIL. We can simplify
    this by just using autoload and turning the @@class_map into a simple
    case statement.
    
    Fixes sparklemotion#27
    brasic committed Jun 28, 2023
    Configuration menu
    Copy the full SHA
    bf6391b View commit details
    Browse the repository at this point in the history
  2. Further remove autoloading, the issue still repros on jruby and truffle

    Repro:
    
        require 'http/cookie'
    
        # We only care about the first exception, not all of them
        Thread.report_on_exception = false
    
        100.times.map do
          Thread.new do
            HTTP::CookieJar::HashStore.new
          end
        end.each(&:join)
    
    The above will reliably trigger an exception on all versions of
    TruffleRuby and many versions of JRuby.  For example:
    
            $ ruby -v
            truffleruby 22.3.1, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
            $ ruby repro.rb
            /home/cbrasic/repos/http-cookie/lib/http/cookie_jar/abstract_store.rb:50:in `initialize': undefined method `each_pair' for nil:NilClass (NoMethodError)
                    from repro.rb:10:in `block (2 levels) in <main>'
    
            $ jruby --version
            jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f OpenJDK 64-Bit Server VM 25.372-b07 on 1.8.0_372-b07 +jit [linux-x86_64]
            $ jruby repro.rb
            NameError: can't resolve constant HashStore after loading http/cookie_jar/hash_store
                  const_missing at /home/cbrasic/.asdf/installs/ruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/http-cookie-1.0.5/lib/http/cookie_jar.rb:25
              block in repro.rb at repro.rb:10
    brasic committed Jun 28, 2023
    Configuration menu
    Copy the full SHA
    48ce295 View commit details
    Browse the repository at this point in the history

Commits on Jun 29, 2023

  1. Add jruby runtime exclusion to abstract store

    gemspec excludes sqlite3 from installing under jruby, so the
    mozilla_store.rb file will raise LoadError under JRuby.
    
    To avoid an undefined constant under jruby define a fake one that just
    raises.
    brasic committed Jun 29, 2023
    Configuration menu
    Copy the full SHA
    20d9927 View commit details
    Browse the repository at this point in the history

Commits on Jun 30, 2023

  1. Remove circular requires

        <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85: warning: <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85: warning: loading in progress, circular require considered harmful - /home/cbrasic/repos/http-cookie/lib/http/cookie_jar.rb
                from /home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/gems/3.3.0+0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in  `<main>'
                from /home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/gems/3.3.0+0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in  `select'
                from /home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/gems/3.3.0+0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in  `block in <main>'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from /home/cbrasic/repos/http-cookie/test/test_http_cookie.rb:2:in  `<top (required)>'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from /home/cbrasic/repos/http-cookie/test/helper.rb:4:in  `<top (required)>'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from /home/cbrasic/repos/http-cookie/lib/http/cookie.rb:7:in  `<top (required)>'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from /home/cbrasic/repos/http-cookie/lib/http/cookie_jar.rb:325:in  `<top (required)>'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from /home/cbrasic/repos/http-cookie/lib/http/cookie_jar/abstract_store.rb:115:in  `<top (required)>'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from /home/cbrasic/repos/http-cookie/lib/http/cookie_jar/hash_store.rb:2:in  `<top (required)>'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
                from <internal:/home/cbrasic/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:85:in  `require'
    brasic committed Jun 30, 2023
    Configuration menu
    Copy the full SHA
    401a002 View commit details
    Browse the repository at this point in the history

Commits on Jul 3, 2023

  1. Configuration menu
    Copy the full SHA
    e8dcdb4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5a71a8b View commit details
    Browse the repository at this point in the history