Skip to content

LOADED_FEATURES internal index not working correctly #5590

@headius

Description

@headius

As part of work on eliminating all builtin libraries (so Shopify/bootsnap can cache require paths and lookups across runs) I ran into an issue with our logic to "provide" loaded features.

In MRI, rb_provide adds entries to the loaded features cache such that a simple require of the same name will be short-circuited.

We have similar logic, but it appears that the index where we store the short names either doesn't work properly or is getting wiped out.

This manifested in errors attempting to load the internal (provided) enumerator.rb, thread.rb, complex,rb, and rational.rb similar to the failures seen here: https://travis-ci.org/jruby/jruby/builds/489301097

Basically, because the loaded features cache didn't work right, it attempted to actually load those files. Since they don't exist, it produced an error.

I tracked one breakage down to the following lines in test/jruby/test_file.rb:

      with_load_path("file:" + File.expand_path("test/jruby/dir with spaces/test_jar.jar") + "!/abc") do
        assert require('foo')
        assert $LOADED_FEATURES.pop =~ /foo\.rb$/
      end

Either the LOAD_PATH or the LOADED_FEATURES manipulation here prevents JRuby from seeing that enumerator.rb is already provided, and a later test fails when it tries to require 'enumerator'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions