JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-5320

require needs to treat case-insensitive file paths in LOADED_FEATURES as case-insensitive for searching purposes

    Details

    • Number of attachments :
      0

      Description

      require searches $" for loaded features when deciding whether to load them or not. However it does this with a case-sensitive search, and on case-insensitive filesystems the search might fail if two requires use different casing (or if internal file path processing changes case, such as C: to c. It should be modified to treat loaded features on case-insensitive filesystems with case-insensitive searching.

      I'm committing an initial fix for this that assumes if jruby home is on a case-insensitive filesystem, all loaded features searches should be done case-insensitively. This is not adequate since jruby may be installed on a case-sensitive filesystem and libraries loaded from a case-insensitive filesystem, or vice versa. It really needs to be done on a feature-by-feature basis. This may or may not be possible.

        Activity

        Hide
        Nick Sieger added a comment -

        Just merged a3afa944 from John that he says improves this somewhat. Still need this to be open?

        Show
        Nick Sieger added a comment - Just merged a3afa944 from John that he says improves this somewhat. Still need this to be open?
        Hide
        John Firebaugh added a comment -

        That commit reclaims most of the performance loss, but I think the bug was being kept open for other reasons.

        Show
        John Firebaugh added a comment - That commit reclaims most of the performance loss, but I think the bug was being kept open for other reasons.
        Hide
        Hiroshi Nakamura added a comment -

        I handled http://redmine.ruby-lang.org/issues/4255 and just have re-closed it as 'Rejected' (Heh, I don't like the word 'reject'.) CRuby 1.9 stores expanded path String in $LOADED_FEATURES. It's not a String specified by script but a String returned by a file system so there's no case-mixing issue as far as developers don't insert Strings to $LOADED_FEATURES by hand.

        So for JRuby, I'm going to remove case-insensitivity feature for 1.9 and 1.8.

        1.9 mode should be safe as I described above. If it's not safe, there's another bug around expand path or classpath handling I think.

        For 1.8 mode, it might cause a problem for double loading but it's acceptable for users I think because CRuby 1.8.7 has the same issue.

          C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>ruby -v
          ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mswin32]
          
          C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>copy con foo.rb
          p :LOADED
          ^Z
          
          C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>ruby -I. -e "requ
          ire 'foo'; require 'Foo'; require 'FOO'; require 'foo.rb'; p $LOADED_FEATURES"
          :LOADED
          :LOADED
          :LOADED
          ["enumerator.so", "foo.rb", "Foo.rb", "FOO.rb"]
        

        I'll update master branch first. How about jruby-1_6?

        Show
        Hiroshi Nakamura added a comment - I handled http://redmine.ruby-lang.org/issues/4255 and just have re-closed it as 'Rejected' (Heh, I don't like the word 'reject'.) CRuby 1.9 stores expanded path String in $LOADED_FEATURES. It's not a String specified by script but a String returned by a file system so there's no case-mixing issue as far as developers don't insert Strings to $LOADED_FEATURES by hand. So for JRuby, I'm going to remove case-insensitivity feature for 1.9 and 1.8. 1.9 mode should be safe as I described above. If it's not safe, there's another bug around expand path or classpath handling I think. For 1.8 mode, it might cause a problem for double loading but it's acceptable for users I think because CRuby 1.8.7 has the same issue. C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mswin32] C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>copy con foo.rb p :LOADED ^Z C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>ruby -I. -e "requ ire 'foo'; require 'Foo'; require 'FOO'; require 'foo.rb'; p $LOADED_FEATURES" :LOADED :LOADED :LOADED ["enumerator.so", "foo.rb", "Foo.rb", "FOO.rb"] I'll update master branch first. How about jruby-1_6?
        Hide
        Hiroshi Nakamura added a comment -

        Committed to master. Sorry for writing the similar thing again and again.

        commit 65c07ea2a5aa7827e415dd7f12ea475e17399bbf
        Author: Hiroshi Nakamura <nahi@ruby-lang.org>
        Date:   Mon May 23 12:44:17 2011 +0900
        
            JRUBY-5320: remove case-insensitive LOADED_FEATURES scanning
            
            6394276 introduced case-insensitive LOADED_FEATURES search on case-insensitive
            File System; Windows and Mac OS X. But in 1.9 (in both JRuby and CRuby),
            LOADED_FEATURES stores expanded path so it should not be a problem as far as
            we compare expanded path with LOADED_FEATURES. After merging require_protection
            branch, master branch should handle expanded path correctly now.
            So I revert the case-insensitive FS feature.
            
            It still be problematic in 1.8 mode but CRuby 1.8 has the same issue. 1.8
            users should aware of this problem.
            
            NB: JRuby has extended feature loading for *.jar and *.class so it might cause
            a problem for these extensions. I don't find any problem at present though.
        
        Show
        Hiroshi Nakamura added a comment - Committed to master. Sorry for writing the similar thing again and again. commit 65c07ea2a5aa7827e415dd7f12ea475e17399bbf Author: Hiroshi Nakamura <nahi@ruby-lang.org> Date: Mon May 23 12:44:17 2011 +0900 JRUBY-5320: remove case-insensitive LOADED_FEATURES scanning 6394276 introduced case-insensitive LOADED_FEATURES search on case-insensitive File System; Windows and Mac OS X. But in 1.9 (in both JRuby and CRuby), LOADED_FEATURES stores expanded path so it should not be a problem as far as we compare expanded path with LOADED_FEATURES. After merging require_protection branch, master branch should handle expanded path correctly now. So I revert the case-insensitive FS feature. It still be problematic in 1.8 mode but CRuby 1.8 has the same issue. 1.8 users should aware of this problem. NB: JRuby has extended feature loading for *.jar and *.class so it might cause a problem for these extensions. I don't find any problem at present though.
        Hide
        Hiroshi Nakamura added a comment -

        Closing. The fix is in 1.7.0. I don't think whole require fixes at master is suitable for stable branch.

        Show
        Hiroshi Nakamura added a comment - Closing. The fix is in 1.7.0. I don't think whole require fixes at master is suitable for stable branch.

          People

          • Assignee:
            Hiroshi Nakamura
            Reporter:
            Charles Oliver Nutter
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: