Project

General

Profile

Bug #9257

flock OS dependency problem in RubyGems

Added by ngoto (Naohisa Goto) almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.1.0dev (2013-12-16)
[ruby-core:59178]

Description

On Solaris, after r44157, many tests of RubyGems failed or raise error during make test-all.

For example,

44) Failure:
TestGemDependencyInstaller#test_install_security_policy [/XXX/test/rubygems/test_gem_dependency_installer.rb:846]:
[Gem::Security::Exception] exception expected, not
Class: Errno::EBADF
Message: <"Bad file number @ rb_file_flock - /var/tmp/test_rubygems_21075/spec_c
ache/gems.example.com%80/quick/Marshal.4.8/b-1.gemspec">
---Backtrace---
/XXX/lib/rubygems.rb:768:in flock'
/XXX/lib/rubygems.rb:768:in
block in read_binary'
/XXX/lib/rubygems.rb:767:in open'
/XXX/lib/rubygems.rb:767:in
read_binary'
/XXX/lib/rubygems/source.rb:133:in fetch_spec'
/XXX/lib/rubygems/resolver/index_specification.rb:64:in
spec'
/XXX/lib/rubygems/resolver/specification.rb:85:in installable_platform?'
/XXX/lib/rubygems/platform.rb:34:in
installable?'
/XXX/lib/rubygems/resolver.rb:426:in block in select_local_platforms'
/XXX/lib/rubygems/resolver.rb:425:in
select'
/XXX/lib/rubygems/resolver.rb:425:in select_local_platforms'
/XXX/lib/rubygems/resolver.rb:200:in
find_possible'
/XXX/lib/rubygems/resolver.rb:327:in resolve_for'
/XXX/lib/rubygems/resolver.rb:165:in
resolve'
/XXX/lib/rubygems/request_set.rb:238:in resolve'
/XXX/lib/rubygems/dependency_installer.rb:434:in
resolve_dependencies'
/XXX/lib/rubygems/dependency_installer.rb:371:in `install'

/XXX/test/rubygems/test_gem_dependency_installer.rb:847:in `block in test_install_security_policy'

46) Error:
TestGemResolverLockSpecification#test_install:
Errno::EBADF: Bad file number @ rb_file_flock - /var/tmp/test_rubygems_21075/gems/a-2.gem
/XXX/lib/rubygems.rb:768:in flock'
/XXX/lib/rubygems.rb:768:in
block in read_binary'
/XXX/lib/rubygems.rb:767:in open'
/XXX/lib/rubygems.rb:767:in
read_binary'
/XXX/lib/rubygems/test_utilities.rb:328:in block in setup_fetcher'
/XXX/lib/rubygems/test_utilities.rb:324:in
each'
/XXX/lib/rubygems/test_utilities.rb:324:in setup_fetcher'
/XXX/lib/rubygems/test_utilities.rb:247:in
execute'
/XXX/lib/rubygems/test_utilities.rb:207:in declare'
/XXX/lib/rubygems/test_case.rb:1207:in
spec_fetcher'
/XXX/test/rubygems/test_gem_resolver_lock_specification.rb:36:in `test_install'

The failures/errors is caused in line 768 in lib/rubygems.rb,
in the self.read_binary method.

def self.read_binary(path)
File.open path, binary_mode do |f|
f.flock(File::LOCK_EX)
f.read
end
end

On Solaris (and probably on JRuby), files opened with read-only mode can not be exclusively locked by using flock.

FYI, when similar problem was found in Rails, the solution was to open the file with read-write mode.
https://rails.lighthouseapp.com/projects/8994/tickets/6662-fileflock-cant-lock-read-only-file-for-exclusive-access

Associated revisions

Revision f8bcd57c
Added by drbrain (Eric Hodel) almost 6 years ago

  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 44286
Added by drbrain (Eric Hodel) almost 6 years ago

  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

Revision 44286
Added by drbrain (Eric Hodel) almost 6 years ago

  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

Revision 44286
Added by drbrain (Eric Hodel) almost 6 years ago

  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

Revision 44286
Added by drbrain (Eric Hodel) almost 6 years ago

  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

Revision 44286
Added by drbrain (Eric Hodel) almost 6 years ago

  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

Revision 44286
Added by drbrain (Eric Hodel) almost 6 years ago

  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

History

Updated by ngoto (Naohisa Goto) almost 6 years ago

  • Description updated (diff)

Updated by drbrain (Eric Hodel) almost 6 years ago

  • Status changed from Open to Assigned
  • Assignee set to drbrain (Eric Hodel)

I will fix this tonight, Pacific Time.

#3

Updated by drbrain (Eric Hodel) almost 6 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44286.
Naohisa, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/rubygems: Update to RubyGems master af60443. Changes include:

    • Improved speed of gem install --ignore-dependencies.
    • Open read-write for exclusive flock. [ruby-trunk - Bug #9257]
    • Remove specification before install to prevent infinite loop.

Also available in: Atom PDF