Bugs item #26840, was opened at 2009-08-04 13:16
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=26840&group_id=126

Category: other
Group: None
>Status: Closed
Resolution: Rejected
Priority: 3
Submitted By: Ryan Riley (panesofglass)
Assigned to: Eric Hodel (drbrain)
Summary: Computed hash in dependency.rb and specification.rb is sometimes too 
large.

Initial Comment:
The current hash algorithm in dependency.rb (line 138) and specification.rb 
(line 658) can sometimes create a hash that is too large. In particular, this 
is causing problems in IronRuby gems, but this is also possible in MRI.

Suggested fixes are:

edit: c:/ruby/libs/ruby/site_ruby/1.8/rubygems/dependency.rb;C840659
File: dependency.rb
===================================================================
--- c:/ruby/libs/ruby/site_ruby/1.8/rubygems/dependency.rb;C840659  (server)    
6/23/2009 1:21 PM
+++ c:/ruby/libs/ruby/site_ruby/1.8/rubygems/dependency.rb
@@ -112,7 +112,7 @@
   end
 
   def hash # :nodoc:
-    name.hash + type.hash + version_requirements.hash
+    name.hash ^ type.hash ^ version_requirements.hash
   end
 
 end
===================================================================
edit: c:/ruby/libs/ruby/site_ruby/1.8/rubygems/specification.rb;C908357
File: specification.rb
===================================================================
--- c:/ruby/libs/ruby/site_ruby/1.8/rubygems/specification.rb;C908357  (server) 
   6/23/2009 1:24 PM
+++ c:/ruby/libs/ruby/site_ruby/1.8/rubygems/specification.rb
@@ -661,9 +661,8 @@
     private :same_attributes?
 
     def hash # :nodoc:
-      @@attributes.inject(0) { |hash_code, (name, default_value)|
-        n = self.send(name).hash
-        hash_code + n
+      @@attributes.inject(612553) { |hash_code, (name, default_value)|
+        hash_code ^ self.send(name).hash
       }
     end
 
===================================================================

----------------------------------------------------------------------

Comment By: Ryan Riley (panesofglass)
Date: 2009-08-21 18:04

Message:
I reset state and resolution in hopes of getting a response.

----------------------------------------------------------------------

Comment By: Ryan Riley (panesofglass)
Date: 2009-08-11 06:56

Message:
Not sure how when rb_hash is used, but Array#hash in MRI can 
misbehave too if one of the array elements returns a large 
hash value:

class C
  def hash
    100000000000000000000
  end
end

[C.new].hash  # => in `hash': bignum too big to convert into 
`long' (RangeError)

REXML has a similar issue. http://redmine.ruby-
lang.org/issues/show/1883 tracks the issue, and MRI will be 
fixing the issue.

----------------------------------------------------------------------

Comment By: Eric Hodel (drbrain)
Date: 2009-08-10 17:02

Message:
It's not too large, see rb_hash().  IronRuby should be casting the value down 
to something it can accept.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=26840&group_id=126
_______________________________________________
Rubygems-developers mailing list
http://rubyforge.org/projects/rubygems
Rubygems-developers@rubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-developers

Reply via email to